test/TensorFlowNET.Examples/ImageProcess/RetrainImageClassifier.cs
/// <summary>
/// Inserts the operations we need to evaluate the accuracy of our results.
/// </summary>
/// <param name="result_tensor"></param>
/// <param name="ground_truth_tensor"></param>
/// <returns></returns>
Inserts the operations we need to evaluate the accuracy of our results.
Inserts the operations we need to evaluate the accuracy of our results .
private (Tensor, Tensor) add_evaluation_step(Tensor result_tensor, Tensor ground_truth_tensor)
        {
            Tensor evaluation_step = null, correct_prediction = null, prediction = null;
            with(tf.name_scope("accuracy"), scope =>
            {
                with(tf.name_scope("correct_prediction"), delegate
                {
                    prediction = tf.argmax(result_tensor, 1);
                    correct_prediction = tf.equal(prediction, ground_truth_tensor);
                });
                with(tf.name_scope("accuracy"), delegate
                {
                    evaluation_step = tf.reduce_mean(tf.cast(correct_prediction, tf.float32));
                });
            });
            tf.summary.scalar("accuracy", evaluation_step);
            return (evaluation_step, prediction);
        }
private ( Tensor , Tensor ) add_evaluation_step ( Tensor result_tensor , Tensor ground_truth_tensor ) { Tensor evaluation_step = null , correct_prediction = null , prediction = null ; with ( tf . name_scope ( " " ) , scope => { with ( tf . name_scope ( " " ) , delegate { prediction = tf . argmax ( result_tensor , 1 ) ; correct_prediction = tf . equal ( prediction , ground_truth_tensor ) ; } ) ; with ( tf . name_scope ( " " ) , delegate { evaluation_step = tf . reduce_mean ( tf . cast ( correct_prediction , tf . float32 ) ) ; } ) ; } ) ; tf . summary . scalar ( " " , evaluation_step ) ; return ( evaluation_step , prediction ) ; }
Inserts the operations we need to evaluate the accuracy of our results.
Inserts the operations we need to evaluate the accuracy of our results .
None
result_tensor
Tensor
None
ground_truth_tensor
Tensor
None