我在Tensorflow上设置了带有Tflearn的CNN。我想训练它应用图像滤镜,所以我通过提供一对前/后一对单通道灰度513x217px图像data
和data2
开始。这是我写的代码:
import tensorflow as tf
import tflearn
import numpy as np
#data and data2 are already defined. They're both a list of lists.
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
network = input_data(shape=[None, np.shape(data)[0], np.shape(data)[1], 1], name='input')
network = conv_2d(network, 256, 3, activation='relu', regularizer="L2")
network = regression(network, optimizer='adam', learning_rate=0.01,
loss='categorical_crossentropy', name='target')
model = tflearn.DNN(network, tensorboard_verbose=0)
model.fit({'input': data}, {'target': data2}, n_epoch=20,
snapshot_step=100, show_metric=True, run_id='convnet_mnist')
当我运行它时,我收到此错误:
ValueError: Cannot feed value of shape (64, 217) for Tensor u'input/X:0', which has shape '(?, 513, 217, 1)'
我不明白这个错误,因为我的代码中没有出现数字64。它似乎表明输入格式不正确,但我无法告诉如何解决它。有谁知道造成这种情况的原因是什么?