metrics.py 文件源码

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

项目:tflearn 作者: tflearn 项目源码 文件源码
def r2_op(predictions, targets):
    """ r2_op.

    An op that calculates the standard error.

    Examples:
        ```python
        input_data = placeholder(shape=[None, 784])
        y_pred = my_network(input_data) # Apply some ops
        y_true = placeholder(shape=[None, 10]) # Labels
        stderr_op = r2_op(y_pred, y_true)

        # Calculate standard error by feeding data X and labels Y
        std_error = sess.run(stderr_op, feed_dict={input_data: X, y_true: Y})
Arguments:
    predictions: `Tensor`.
    targets: `Tensor`.

Returns:
    `Float`. The standard error.

"""
with tf.name_scope('StandardError'):
    a = tf.reduce_sum(tf.square(predictions))
    b = tf.reduce_sum(tf.square(targets))
    return tf.divide(a, b)

```

评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号