fudannlp16 / focal-loss

Tensorflow version implementation of focal loss for binary and multi classification
108 stars 27 forks source link

您好,我将tf.nn.sparse_softmax_cross_entropy_with_logits改为focal-loss时出现了以下问题: #5

Open lilmangolil opened 5 years ago

lilmangolil commented 5 years ago

InvalidArgumentError (see above for traceback): tags and values not the same shape: [] != [256] ,请问怎样解决?谢谢(^▽^)

jamiechoi1995 commented 5 years ago

Add tf.reduce_mean. example: before: loss = focal_loss_softmax(flaten_cls_targets, cls_pred) (params['negative_ratio'] + 1.) after: loss = tf.reduce_mean(focal_loss_softmax(flaten_cls_targets, cls_pred) (params['negative_ratio'] + 1.))