Machine learning TensorFlow错误:“;登录和标签的大小必须相同;,温暖的春风”;教程“;

Machine learning TensorFlow错误:“;登录和标签的大小必须相同;,温暖的春风”;教程“;,machine-learning,tensorflow,image-segmentation,Machine Learning,Tensorflow,Image Segmentation,我目前正在关注这一点,在我因为tensorflow更新做了一些更改之后,我得到了以下错误: tensorflow.python.framework.errors\u impl.InvalidArgumentError:logits和labels的大小必须相同:logits\u大小=[399360,2]labels\u大小=[409920,2] [[Node:SoftmaxCrossEntropyWithLogits=SoftmaxCrossEntropyWithLogits[T=DT\u FLO

我目前正在关注这一点,在我因为tensorflow更新做了一些更改之后,我得到了以下错误:

tensorflow.python.framework.errors\u impl.InvalidArgumentError:logits和labels的大小必须相同:logits\u大小=[399360,2]labels\u大小=[409920,2] [[Node:SoftmaxCrossEntropyWithLogits=SoftmaxCrossEntropyWithLogits[T=DT\u FLOAT,\u device=“/job:localhost/replica:0/task:0/cpu:0”](重塑\u 2,重塑\u 3)]

有人能帮我做这个吗

守则的更改:

#Replaced concat_dim=2 with axis=2
combined_mask = tf.concat(axis=2, values=[bit_mask_class, bit_mask_background])

#Update the import of urllib2 to urllib3

#Replace tf.pack with tf.stack
upsampled_logits_shape = tf.stack([
downsampled_logits_shape[0],
downsampled_logits_shape[1] * upsample_factor,
downsampled_logits_shape[2] * upsample_factor,
downsampled_logits_shape[3]])

出现此错误的原因是,当您向函数提供
409920
标签时,logit的数量为
399360
。函数
tf.nn.softmax\u cross\u entropy\u with\u logits
要求每个logit有一个标签,它会崩溃,因为您提供的标签比logit多


至于发生这种情况的原因,您应该发布对代码所做的更改。

当您向函数提供
409920
标签时,由于登录次数为
399360
,因此会出现此错误。函数
tf.nn.softmax\u cross\u entropy\u with\u logits
要求每个logit有一个标签,它会崩溃,因为您提供的标签比logit多

至于为什么会发生这种情况,您应该发布对代码所做的更改