TensorFlow-and-DeepLearning-Tutorial
TensorFlow-and-DeepLearning-Tutorial copied to clipboard
全连接网络
全连接网络中的损失函数为什么是用tf.matmul(hidden, fc2_weight) + fc2_biases, 和 label比较呢?而不是用softmax, argmax后的比较呢?
你可以将代码哪一行提一下吗?都一年了,我有些忘记了。
`【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层转化成概率呢再比较呢?
函数名应该表明了用途tf.nn.softmax_cross_entropy_with_logits(logits, self.tf_train_labels)