2017-07-26 40 views
1

我正在下面这个 tutorial和我做,因为tensorflow更新的一些变化后,我得到这个错误:TensorFlow错误:“logits和标签必须是相同的大小”,warmspringwinds“教程”

tensorflow.python.framework.errors_impl.InvalidArgumentError: logits and labels must be same size: logits_size=[399360,2] labels_size=[409920,2] [[Node: SoftmaxCrossEntropyWithLogits = SoftmaxCrossEntropyWithLogits[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](Reshape_2, Reshape_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]]) 

回答

0

将引发错误,因为logits数为399360,而你所提供的功能与409920标签。函数tf.nn.softmax_cross_entropy_with_logits需要为每个logit使用一个标签,并且因为您提供的标签多于logits而导致崩溃。至于为什么发生这种情况,您应该发布您对代码所做的更改。

+0

我更新了帖子 – cat96

相关问题