我是使用theano后端的keras的新手,我想使用卷积创建一个CNN知道输入形状等于输出形状(1,33,33)
model = Sequential()
input_shape=(33,33,1)
model.add(Convolution2D(64, (9, 9), padding='same', input_shape=input_shape, activation='relu'))
model.add(Convolution2D(32, (1, 1), padding='same', activation='relu'))
model.add(Convolution2D(1, (5, 5), padding='same', ))
model.compile(Adam(lr=0.001), 'mse')
model.summary()
model.fit(inputs, X, batch_size=128, epochs=5, shuffle='batch')
摘要秀
Layer (type) Output Shape Param #
=================================================================
conv2d_66 (Conv2D) (None, 33, 33, 64) 5248
_________________________________________________________________
conv2d_67 (Conv2D) (None, 33, 33, 32) 2080
_________________________________________________________________
conv2d_68 (Conv2D) (None, 33, 33, 1) 801
=================================================================
Total params: 8,129
Trainable params: 8,129
Non-trainable params: 0
和错误
ValueError: Error when checking input: expected conv2d_66_input to have 4 dimensions, but got array with shape (33, 33, 1)
我还尝试在输入和输出4d
中添加维度input=np.expand_dims(inputs,axis=0)
但我总是遇到同样的问题
谢谢你的帮助。