keras交叉熵损失计算中的误差

时间:2019-05-23 12:35:44

标签: tensorflow keras

我试图在keras中使用tf交叉熵损失函数。错误是:

Incompatible shapes: [512,184,55] vs. [512,55]

损失函数是:

def keras_binary_cross_entropy_with_logits(tgt, pred):
return tf.nn.sigmoid_cross_entropy_with_logits(labels=tgt, logits=pred)

这个想法是对目标进行二值化的多标签分类。 y_true的形状为[batch_size,label_vocab_length],y_pred的形状为[batch_size,sequnece_length,label_vocab_length]。在上面的示例y_true =[512,55]y_pred=[512,184,55中。

完全错误

InvalidArgumentError: Incompatible shapes: [512,184,55] vs. [512,55]
 [[{{node training_2/RMSprop/gradients/loss_5/dense_output_loss/logistic_loss/mul_grad/BroadcastGradientArgs}} = BroadcastGradientArgs[T=DT_INT32, _class=["loc:@train...ad/Reshape"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](training_2/RMSprop/gradients/loss_5/dense_output_loss/logistic_loss/mul_grad/Shape, training_2/RMSprop/gradients/loss_5/dense_output_loss/logistic_loss/mul_grad/Shape_1)]]

我在这里想念什么?

0 个答案:

没有答案
相关问题