train.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:image-classification-tensorflow 作者: xuetsing 项目源码 文件源码
def add_evaluation_step(result_tensor, ground_truth_tensor):
    """
    Brief:
        Inserts the operations we need to evaluate the accuracy of our results.
    Args:
        result_tensor: The new final node that produces results.
        ground_truth_tensor: The node we feed ground truth data
        into.
    Returns:
        Tuple of (evaluation step, prediction).
    """
    with tf.name_scope('accuracy'):
        with tf.name_scope('correct_prediction'):
            prediction = tf.argmax(result_tensor, 1)
            correct_prediction = tf.equal(
                    prediction, tf.argmax(ground_truth_tensor, 1))
        with tf.name_scope('accuracy'):
            evaluation_step = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
    tf.summary.scalar('accuracy', evaluation_step)
    return evaluation_step, prediction
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号