全连接网络中的损失函数为什么是用tf.matmul(hidden, fc2_weight) + fc2_biases, 和 label比较呢?而不是用softmax, argmax后的比较呢?
Activity
CreatCodeBuild commentedon Oct 12, 2017
你可以将代码哪一行提一下吗?都一年了,我有些忘记了。
yanglu1994 commentedon Oct 13, 2017
`【model的返回值 return tf.matmul(hidden, fc2_weight) + fc2_biases】
logits = model(self.tf_train_samples)
with tf.name_scope('loss'):
self.loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits, self.tf_train_labels))
self.loss += self.apply_regularization(_lambda=5e-4)`
Label 集是个one-hot集合,里面的值为1可以理解为这个图片为该值的概率为1,可是计算loss函数时,model 的输出直接与label 计算,为啥不添加一个softmax层转化成概率呢再比较呢?
CreatCodeBuild commentedon Oct 13, 2017
函数名应该表明了用途
tf.nn.softmax_cross_entropy_with_logits(logits, self.tf_train_labels)