【发布时间】:2019-04-27 18:03:53
【问题描述】:
我想创建某些受图像启发的 CNN 模型,所以我尝试这样做但没有成功:the image here
当我尝试实现这个架构时
Layer (type) Output Shape Param #
=================================================================
reshape_16 (Reshape) (None, 32, 32, 1) 0
_________________________________________________________________
conv2d_32 (Conv2D) (None, 32, 32, 80) 2080
_________________________________________________________________
max_pooling2d_31 (MaxPooling (None, 16, 16, 80) 0
_________________________________________________________________
batch_normalization_4 (Batch (None, 16, 16, 80) 320
_________________________________________________________________
conv2d_33 (Conv2D) (None, 16, 16, 64) 128064
_________________________________________________________________
max_pooling2d_32 (MaxPooling (None, 8, 8, 64) 0
_________________________________________________________________
batch_normalization_5 (Batch (None, 8, 8, 64) 256
_________________________________________________________________
flatten_15 (Flatten) (None, 4096) 0
_________________________________________________________________
dense_29 (Dense) (None, 1024) 4195328
_________________________________________________________________
dropout_15 (Dropout) (None, 1024) 0
_________________________________________________________________
dense_30 (Dense) (None, 29) 29725
=================================================================
和我在 python 中的代码
model = Sequential()
model.add(Reshape((32,32,1), input_shape=(32,32,1)))
#first layer of cnn
model.add(Conv2D(filters = 80, kernel_size = (5,5),padding = 'Same',
activation ='relu'))
model.add(MaxPooling2D(pool_size=(2,2), strides=(2,2)))
model.add(BatchNormalization())
#second layer of cnn
model.add(Conv2D(filters = 64, kernel_size = (5,5),padding = 'Same',
activation ='relu'))
model.add(MaxPooling2D(pool_size=(2,2), strides=(2,2)))
model.add(BatchNormalization())
#fully connected layer
model.add(Flatten())
model.add(Dense(units = 1024, activation = "relu"))
model.add(Dropout(0.8))
model.add(Dense(29, activation = "softmax"))
model.summary()
我想像图片中那样创建 CNN
【问题讨论】:
-
如果您能详细说明您的疑问或问题,将会很有帮助
-
@ShubhamPanchal 我花了 2 天时间才发帖!!!
-
在知道您的问题之前,我们如何才能给出答案?
标签: python tensorflow keras