Tensorflow, multi label accuracy calculation

前端 未结 2 1528
温柔的废话
温柔的废话 2021-01-30 18:23

I am working on a multi label problem and i am trying to determine the accuracy of my model.

My model:

NUM_CLASSES         


        
2条回答
  •  北海茫月
    2021-01-30 18:57

    # to get the mean accuracy over all labels, prediction_tensor are scaled logits (i.e. with final sigmoid layer)
    correct_prediction = tf.equal( tf.round( prediction_tensor ), tf.round( ground_truth_tensor ) )
    accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
    
    # to get the mean accuracy where all labels need to be correct
    all_labels_true = tf.reduce_min(tf.cast(correct_prediction, tf.float32), 1)
    accuracy2 = tf.reduce_mean(all_labels_true)
    

    reference: https://gist.github.com/sbrodehl/2120a95d57963a289cc23bcfb24bee1b

提交回复
热议问题