Пример #1
0
 def loss_fn(logits, target):
   check_shape_op = control_flow_ops.Assert(
       math_ops.less_equal(array_ops.rank(target), 2),
       ["target's shape should be either [batch_size, 1] or [batch_size]"])
   with ops.control_dependencies([check_shape_op]):
     target = array_ops.reshape(
         target, shape=[array_ops.shape(target)[0], 1])
   return loss_ops.hinge_loss(logits, target)
Пример #2
0
 def loss_fn(logits, target):
   check_shape_op = control_flow_ops.Assert(
       math_ops.less_equal(array_ops.rank(target), 2),
       ["target's shape should be either [batch_size, 1] or [batch_size]"])
   with ops.control_dependencies([check_shape_op]):
     target = array_ops.reshape(
         target, shape=[array_ops.shape(target)[0], 1])
   return loss_ops.hinge_loss(logits, target)