mnist.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:deep_learning_study 作者: jowettcz 项目源码 文件源码
def loss(logits, labels):
  """Calculates the loss from the logits and the labels.

  Args:
    logits: Logits tensor, float - [batch_size, NUM_CLASSES].
    labels: Labels tensor, int32 - [batch_size].

  Returns:
    loss: Loss tensor of type float.
  """
  labels = tf.to_int64(labels)
  cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(
      labels=labels, logits=logits, name='xentropy')
  return tf.reduce_mean(cross_entropy, name='xentropy_mean')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号