本文整理汇总了Python中inception.slim.losses.cross_entropy_loss方法的典型用法代码示例。如果您正苦于以下问题:Python losses.cross_entropy_loss方法的具体用法?Python losses.cross_entropy_loss怎么用?Python losses.cross_entropy_loss使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inception.slim.losses
的用法示例。
在下文中一共展示了losses.cross_entropy_loss方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCrossEntropyLossAllCorrect
# 需要导入模块: from inception.slim import losses [as 别名]
# 或者: from inception.slim.losses import cross_entropy_loss [as 别名]
def testCrossEntropyLossAllCorrect(self):
with self.test_session():
logits = tf.constant([[10.0, 0.0, 0.0],
[0.0, 10.0, 0.0],
[0.0, 0.0, 10.0]])
labels = tf.constant([[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
loss = losses.cross_entropy_loss(logits, labels)
self.assertEquals(loss.op.name, 'CrossEntropyLoss/value')
self.assertAlmostEqual(loss.eval(), 0.0, 3)
示例2: testCrossEntropyLossAllWrong
# 需要导入模块: from inception.slim import losses [as 别名]
# 或者: from inception.slim.losses import cross_entropy_loss [as 别名]
def testCrossEntropyLossAllWrong(self):
with self.test_session():
logits = tf.constant([[10.0, 0.0, 0.0],
[0.0, 10.0, 0.0],
[0.0, 0.0, 10.0]])
labels = tf.constant([[0, 0, 1],
[1, 0, 0],
[0, 1, 0]])
loss = losses.cross_entropy_loss(logits, labels)
self.assertEquals(loss.op.name, 'CrossEntropyLoss/value')
self.assertAlmostEqual(loss.eval(), 10.0, 3)
示例3: testCrossEntropyLossAllWrongWithWeight
# 需要导入模块: from inception.slim import losses [as 别名]
# 或者: from inception.slim.losses import cross_entropy_loss [as 别名]
def testCrossEntropyLossAllWrongWithWeight(self):
with self.test_session():
logits = tf.constant([[10.0, 0.0, 0.0],
[0.0, 10.0, 0.0],
[0.0, 0.0, 10.0]])
labels = tf.constant([[0, 0, 1],
[1, 0, 0],
[0, 1, 0]])
loss = losses.cross_entropy_loss(logits, labels, weight=0.5)
self.assertEquals(loss.op.name, 'CrossEntropyLoss/value')
self.assertAlmostEqual(loss.eval(), 5.0, 3)