tensorflow中tf.loss.log_loss(标签、预测)的输入是什么?
谁能举一些例子? 官方文件中没有指南。 我想知道什么类型的标签和预测?tensorflow中tf.loss.log_loss(标签、预测)的输入是什么?,tensorflow,Tensorflow,谁能举一些例子? 官方文件中没有指南。 我想知道什么类型的标签和预测? 谢谢。输入是张量,第一个包含对数据点的正确预测,第二个是模型对数据点的实际预测。这些张量可以表示单个数据点(如示例中所示),也可以表示批次。它们必须有相同的形状 示例: import tensorflow as tf """ Minimal example """ with tf.Session() as sess: loss = tf.losses.log_loss(tf.Variable([0., 1., 0.
谢谢。输入是张量,第一个包含对数据点的正确预测,第二个是模型对数据点的实际预测。这些张量可以表示单个数据点(如示例中所示),也可以表示批次。它们必须有相同的形状 示例:
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)
预测是否涉及logits或softmax概率?如果是,那又有什么关系呢?