ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your m

错误显示:
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected.

代码如下:
(x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()
x_train = x_train.astype(‘float32’) / 255
x_test = y_train.astype(‘float32’) / 255
y_train = keras.utils.to_categorical(y_train, 10)
y_test = keras.utils.to_categorical(y_test, 10)

model.compile(optimizer=keras.optimizers.RMSprop(1e-3),
loss=‘categorical_crossentropy’,
metrics=[‘acc’])
model.fit(x_train, y_train,batch_size=64,epochs=1,validation_split=0.2)

错误原因:
参数不匹配
结果将代码修改了一下,结果还是出错。修改如下:
model.fit([x_train,x_train], y_train,batch_size=64,epochs=1,validation_split=0.2)

model.fit([x_train,x_train], y_train, validation_data=([x_val,x_val], y_val),epochs=1, batch_size=64)

依旧出错。

结果,我发现,我的代码少了一部分。少了model的建立,那一部分。
加上之后,就好了。

说明代码没有问题。

你可能感兴趣的:(tensorflow2.0学习)