当我写 tensorflow 演示时,我arg_max()
在定义中找到了这个函数correct_predition
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(
logits=hypothesis,labels=Y))
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)
correct_prediction = tf.equal(tf.arg_max(hypothesis,1),tf.arg_max(Y,1))
返回张量轴上具有最大值的索引。(这是来自 TF 的 API)
因为我们使用' softmax_cross_entropy_with_logits
',
预测 ( hypothesis
) 表示为概率
arg_max()
我们将通过函数获得最大预测概率的索引hypothesis
但是Y
是标签,这不是我们需要使用的概率tf.arg_max(Y,1)
吗?