nn_with_momentum.py 文件源码

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

项目:DataMining 作者: lidalei 项目源码 文件源码
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(logits, labels, name = 'xentropy')
    loss = tf.reduce_mean(cross_entropy, name = 'xentropy_mean')
    return loss
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号