如何调整标签张量的大小,以便可以在tf.nn.sigmoid_cross_entropy_with_logits中使用它

时间:2018-08-30 09:26:39

标签: python tensorflow

我有以下问题:

 cross_entropy = tf.nn.sigmoid_cross_entropy_with_logits(labels=labels, logits=logits)

这给了我

tensorflow.python.framework.errors_impl.InvalidArgumentError: Can not squeeze dim[1], expected a dimension of 1, got 18000 for 'remove_squeezable_dimensions/Squeeze' (op: 'Squeeze') with input shapes: [1024,18000]

之所以有意义,是因为该函数期望一维的东西。所以我尝试了:

cross_entropy = tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.argmax(labels, axis=1), logits=logits)

这给了我

ValueError: logits and labels must have the same shape ((1024, 18000) vs (1024,))

所以我的标签只是一定大小的图像,所以我在这里有点迷茫,当标签尺寸更大时,我应该如何为函数赋予一维的东西:/

0 个答案:

没有答案