ValueError: Error when checking input:
expected input_1 to have 3 dimensions, but got array with shape (6, 7)
_____________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==============================================================================
input_1 (InputLayer) (None, 6, 7) 0
out1, out2 = model.predict(board)
inputs = Input(shape=(6,7))
inputs_reshape = Reshape((6,7,1))(inputs) # channels, batch_size, rows, cols
net = Conv2D(4, kernel_size=3, activation='relu',
padding='same', data_format='channels_last')(inputs_reshape)
net = Flatten()(net)
pi = Dense(7, activation='softmax', name='pi')(net)
v = Dense(1, activation='tanh', name='v')(net)
model = Model(inputs=inputs, outputs=[v, pi])
来自keras.io文档,它说shape
的{{1}}维度不包括批量大小,并且Input()
默认设置mdoel.predict()
。
如果batch_size=32
期望model.predict(data)
为data.shape
,那么(batches, 6,7)
和model.predict(data, batch_size=1
有什么区别
答案 0 :(得分:0)
是的,模型的batch_shape
是(None, 6, 7)
,三个维度。第一个值None
是批处理大小(可以是任意值)。
因此,正如batch_shape
确定的那样,期望您的数据具有3维。