[英]Tensorflow error using my own data
I've been playing with the Tensorflow library doing the tutorials. 我一直在玩Tensorflow库做教程。 Now I wanted to play with my own data, but I fail horribly.
现在我想玩我自己的数据,但我失败了。 This is perhaps a noob question but I can't figure it out.
这可能是一个noob问题,但我无法弄清楚。
I'm using this example: https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3%20-%20Neural%20Networks/convolutional_network.py 我正在使用这个例子: https : //github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3%20-%20Neural%20Networks/convolutional_network.py
I want to use my own images, for converting my images to use with tensorflow i'm using this: https://github.com/HamedMP/ImageFlow/blob/master/ImageFlow.py 我想使用我自己的图像,将我的图像转换为使用tensorflow我正在使用它: https : //github.com/HamedMP/ImageFlow/blob/master/ImageFlow.py
Now I change the parameters in the example from this: 现在我更改示例中的参数:
n_input = 784
n_classes = 10
to this: 对此:
n_input = 9216
n_classes = 2
I did that because my images are 96 * 96 and there are only 2 classes of my images 我这样做是因为我的图像是96 * 96而且我的图像只有两类
I also change the weights and biases to the numbers I need. 我也将重量和偏差改为我需要的数字。
I read the data like this: 我读了这样的数据:
batch_xs = imgReader.read_images(pathname);
imgReader being the ImageFlow file imgReader是ImageFlow文件
but when I try to run it I gives me an error: 但是当我尝试运行它时,我给了我一个错误:
ValueError: Cannot feed value of shape (104, 96, 96, 1) for Tensor
u'Placeholder:0', which has shape (Dimension(None), Dimension(9216))
I feel like i'm overlooking something small but I don't see it. 我觉得我忽视了一些小事但我没有看到它。
This error arises because the shape of the data that you're trying to feed (104 x 96 x 96 x 1) does not match the shape of the input placeholder ( batch_size
x 9216, where batch_size
may be variable). 出现此错误的原因是您尝试提供的数据形状(104 x 96 x 96 x 1)与输入占位符的形状不匹配(
batch_size
x 9216,其中batch_size
可能是变量)。
To make it work, add the following line before running a training step: 要使其工作,请在运行训练步骤之前添加以下行:
batch_xs = np.reshape(batch_xs, (-1, 9216))
This uses numpy to reshape the images read in, which are 4-D arrays of batch_size
xhxwx channels, into a batch_size
x 9216 element matrix as expected by the placeholder. 这使用numpy将读入的图像(
batch_size
xhxwx通道的4-D阵列)重新整形为占位符所期望的batch_size
x 9216元素矩阵。
我通过pip升级tensorflow解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.