我想制作一个ConvNet具有与输入之一相同的输出大小。所以,我使用TFLearn库实现了它。因为我只是想要一个满足这些目的的简单示例,所以我只设置一个具有零填充的卷积层,以便与输入具有相同的输出大小。以下是代码:TensorFlow/TFLearn:ValueError:无法提供形状为'(?,64)'的张量u'TargetsData/Y:0'形状(256,400,400)的值。
X = X.reshape([-1, 400, 400, 1])
Y = Y.reshape([-1, 400, 400, 1])
testX = testX.reshape([-1, 400, 400, 1])
testY = testY.reshape([-1, 400, 400, 1])
X, mean = du.featurewise_zero_center(X)
testX = du.featurewise_zero_center(testX, mean)
# Building a Network
net = tflearn.input_data(shape=[None, 400, 400, 1])
net = tflearn.conv_2d(net, 64, 3, padding='same', activation='relu', bias=False)
sgd = tflearn.SGD(learning_rate=0.1, lr_decay=0.96, decay_step=300)
net = tflearn.regression(net, optimizer='sgd',
loss='categorical_crossentropy',
learning_rate=0.1)
# Training
model = tflearn.DNN(net, checkpoint_path='model_network',
max_checkpoints=10, tensorboard_verbose=3)
model.fit(X, Y, n_epoch=100, validation_set=(testX, testY),
show_metric=True, batch_size=256, run_id='network_test')
然而,这些代码产生
ValueError: Cannot feed value of shape (256, 400, 400) for Tensor u'TargetsData/Y:0', which has shape '(?, 64)'
我已经搜查,并检查一些文件的错误,但我似乎无法得到这个工作。
我不熟悉的TF API,但'testX'不会'testX = du.featurewise_zero_center(testX,mean)'后面的元组吗? – erip
@erip对不起,我已经省略了标题部分。该行来自'import tflearn.data_utils as du'。这里,'tflearn.data_utils'是一个与数据预处理相关的头文件。 – David
当然,但它返回X,并且意味着高于。在它下面只返回testX。 – erip