本文介绍了在卷积神经网络中计算特征图的维数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Keras中有卷积神经网络.我需要知道每一层中要素地图的尺寸​​.我的输入是28 x 28像素的图像.我知道有一种方法可以计算这个,但我不确定.以下是我使用Keras的代码段.

I have convolutional neural network in Keras.I need to know the dimensions of the feature maps in each layer.My input is 28 by 28 pixel image. I know theres a way to calculate this I not sure how. Below is my code snippet using Keras.

img_rows, img_cols = 28, 28
nb_filters = 32
nb_pool = 2
nb_conv = 3

model = Sequential()

model.add(Convolution2D(nb_filters, nb_conv, nb_conv, border_mode='valid', input_shape=(1, img_rows, img_cols)))
model.add(Activation('relu'))
model.add(Convolution2D(nb_filters, nb_conv, nb_conv))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))
model.add(Dropout(0.25))

model.add(Convolution2D(64, nb_conv, nb_conv, border_mode='valid'))
model.add(Activation('relu'))
model.add(Convolution2D(64, nb_conv, nb_conv))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))
model.add(Dropout(0.25))

model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))


model.add(Dense(nb_classes))
model.add(Activation('softmax'))

最后,这就是我要画的.谢谢.

At the end of the day, this is what i want to draw. Thank you.

推荐答案

检查文章.

输出体积的空间大小的公式: K *((WF + 2P)/S + 1),其中 W -输入体积大小, F 的Conv层神经元的感受野大小, S -对其应用的步幅, P -在其上使用的零填充量边界 K -转换层的深度.

Formula for spatial size of the output volume: K*((W−F+2P)/S+1), where W - input volume size, F the receptive field size of the Conv Layer neurons, S - the stride with which they are applied, P - the amount of zero padding used on the border, K - the depth of conv layer.

这篇关于在卷积神经网络中计算特征图的维数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 07:20