jus*_*uff 12 python python-2.7 tensorflow
我一直在玩Tensorflow库做教程.现在我想玩我自己的数据,但我失败了.这可能是一个noob问题,但我无法弄清楚.
我正在使用这个例子:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3%20-%20Neural%20Networks/convolutional_network.py
我想使用我自己的图像,将我的图像转换为使用tensorflow我正在使用它:https://github.com/HamedMP/ImageFlow/blob/master/ImageFlow.py
现在我更改示例中的参数:
n_input = 784
n_classes = 10
Run Code Online (Sandbox Code Playgroud)
对此:
n_input = 9216
n_classes = 2
Run Code Online (Sandbox Code Playgroud)
我这样做是因为我的图像是96*96而且我的图像只有两类
我也将重量和偏差改为我需要的数字.
我读了这样的数据:
batch_xs = imgReader.read_images(pathname);
Run Code Online (Sandbox Code Playgroud)
imgReader是ImageFlow文件
但是当我尝试运行它时,我给了我一个错误:
ValueError: Cannot feed value of shape (104, 96, 96, 1) for Tensor
u'Placeholder:0', which has shape (Dimension(None), Dimension(9216))
Run Code Online (Sandbox Code Playgroud)
我觉得我忽视了一些小事但我没有看到它.
mrr*_*rry 17
出现此错误的原因是您尝试输入的数据的形状(104 x 96 x 96 x 1)与输入占位符的形状不匹配(batch_sizex 9216,其中batch_size可能是变量).
要使其工作,请在运行训练步骤之前添加以下行:
batch_xs = np.reshape(batch_xs, (-1, 9216))
Run Code Online (Sandbox Code Playgroud)
这使用numpy将读入的图像(batch_sizexhxwx通道的4-D阵列)重新整形为batch_sizex 9216元素矩阵,如占位符所期望的那样.
| 归档时间: |
|
| 查看次数: |
17820 次 |
| 最近记录: |