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)
```