[英]Difficulties with the dimensions of the Fashion-MNIST Dataset
does someone know how to fix this error?有人知道如何解决这个错误吗? I tried to solve it with the reshape function but it still doesnt work.
我试图通过重塑 function 来解决它,但它仍然不起作用。 I want to train the Fashion-MNIST dataset with VGG16 but I have some difficulties with the dimensions...
我想用 VGG16 训练 Fashion-MNIST 数据集,但我在尺寸方面遇到了一些困难......
I get this error:我收到此错误:
Epoch 1/50
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-84-51241dcc88e5> in <module>()
3 steps_per_epoch=x_train.shape[0]//batch_size,
4 validation_data=val_generator.flow(x_val,y_val,batch_size=batch_size),validation_steps=250,
----> 5 callbacks=[lrr],verbose=1)
5 frames
/usr/local/lib/python3.6/dist-packages/keras/engine/training_utils.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
143 ': expected ' + names[i] + ' to have shape ' +
144 str(shape) + ' but got array with shape ' +
--> 145 str(data_shape))
146 return data
147
ValueError: Error when checking input: expected vgg16_input to have shape (32, 32, 3) but got array with shape (28, 28, 1)
And when I try to fix it with the reshape function I get this error:当我尝试使用重塑 function 修复它时,我收到此错误:
ValueError Traceback (most recent call last)
<ipython-input-11-8ad7b8e95a75> in <module>()
1 #x_train = x_train.reshape(x_train.shape[0],32,32,3)
----> 2 x_train = x_train.reshape(-1,32,32,3)
ValueError: cannot reshape array of size 32928000 into shape (32,32,3)
My input has the shape:我的输入具有以下形状:
(42000, 28, 28, 1)
ValueError: Error when checking input: expected vgg16_input to have shape (32, 32, 3) but got array with shape (28, 28, 1)
ValueError:检查输入时出错:预期 vgg16_input 的形状为 (32, 32, 3) 但得到的数组的形状为 (28, 28, 1)
VGG is expecting the input to be a 32*32
patch; VGG 期望输入是
32*32
的补丁;
ValueError: cannot reshape array of size 32928000 into shape (32,32,3)
ValueError:无法将大小为 32928000 的数组重塑为形状 (32,32,3)
This happens because the array shape isn't completely divisible by the product of your 32*32*3
to get the 4th axis;发生这种情况是因为数组形状不能完全被
32*32*3
的乘积整除以获得第 4 轴;
My input has the shape: (42000, 28, 28, 1)
我的输入具有以下形状: (42000, 28, 28, 1)
Then change (if possible) the vgg_input to accept (28,28,3) patches etc;然后更改(如果可能) vgg_input 以接受(28,28,3)补丁等; (accordingly)
(因此)
Sample Code from here ,示例代码来自这里,
def build(width, height, depth, classes):
# initialize the model along with the input shape to be
# "channels last" and the channels dimension itself
model = Sequential()
inputShape = (height, width, depth)
chanDim = -1
# if we are using "channels first", update the input shape
# and channels dimension
if K.image_data_format() == "channels_first":
inputShape = (depth, height, width)
chanDim = 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.