0
任何人都可以举一些例子吗? 官方文件中没有指南。 我想知道什么类型的标签和预测是? 谢谢。张量流中tf.losses.log_loss(标签,预测)的输入是什么?
任何人都可以举一些例子吗? 官方文件中没有指南。 我想知道什么类型的标签和预测是? 谢谢。张量流中tf.losses.log_loss(标签,预测)的输入是什么?
输入是张量,第一个包含数据点的正确预测,第二个是您的模型为数据点提供的实际预测。这些张量既可以代表一个数据点,也可以代表批次。它们必须具有相同的形状。
例子:
import tensorflow as tf
""" Minimal example """
with tf.Session() as sess:
loss = tf.losses.log_loss(tf.Variable([0., 1., 0.]), tf.Variable([0.1, 0.8, 0.1]))
sess.run(tf.global_variables_initializer())
result = sess.run(loss)
print('Minimal example loss: %f' % result)
tf.reset_default_graph()
""" More realistic example """
with tf.Session() as sess:
# Create placeholders for inputs
X_placeholder = tf.placeholder(tf.float32, [3])
y_placeholder = tf.placeholder(tf.float32, [3])
# Set up the model structure, resulting in a set of predictions
predictions = tf.multiply(X_placeholder, 2.)
# Compute the loss of the calculated predictions
loss = tf.losses.log_loss(y_placeholder, predictions)
# Run the loss tensor with values for the placeholders
result = sess.run(loss, feed_dict={X_placeholder: [0.5, 0.5, 0.5], y_placeholder: [0., 1., 0.]})
print('Realistic example loss: %f' % result)
不'predictions'指logits或SOFTMAX概率?如果是这样,为什么这很重要? – vin