【发布时间】:2016-04-03 19:57:45
【问题描述】:
我一直在尝试通过基于 Internet 上的各种示例实现 SimilarAlexNet 来学习 TensorFlow。基本上扩展 AlexNet 示例 here 以获取 224x224 RGB 图像(而不是 28x28 灰度图像),并根据我在网上找到的其他 AlexNet 实现添加更多层、更改内核大小、步幅等。
已经解决了许多不匹配的形状类型错误,但这个让我很难过:
tensorflow.python.framework.errors.InvalidArgumentError: logits and labels must be same size: logits_size=dim { size: 49 } dim { size: 10 } labels_size=dim { size: 1 } dim { size: 10 }
[[Node: SoftmaxCrossEntropyWithLogits = SoftmaxCrossEntropyWithLogits[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"](Softmax, _recv_Placeholder_1_0/_13)]]
[[Node: gradients/Mean_grad/range_1/_17 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_457_gradients/Mean_grad/range_1", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
49 维特别令人费解。对于调试,我的批量大小目前是 1,如果我将它增加到 2,那么 49 就变成了 98。
如果我记录我传递给的 x 和 y 的形状
sess.run(optimizer, feed_dict={x: batchImages, y: batchLabels, keepProb: P_DROPOUT})
我明白了
x shape: (1, 150528)
y shape: (1, 10)
正如预期的那样:150528 = 224 * 224 RGB 像素,以及代表我的标签的 one-hot 向量。
如果您能帮我们解决这个问题,我们将不胜感激!
更新:此处显示错误的代码:
【问题讨论】:
标签: tensorflow