简体   繁体   English

CNN体系结构-如何解释内核大小表示法

[英]CNN architecture - how to interpret kernel size notation

Using Keras I am trying to rebuild a basic CNN architecture I found in a paper. 我正在尝试使用Keras重建我在论文中发现的基本CNN架构。 The paper describes the architecture as follows: 本文描述了该体系结构,如下所示:

  1. normalized input 36x36 标准化输入36x36
  2. 1st convolutional feature map 32x32 (3@1x5x5 kernel) 第一张卷积特征图32x32(3 @ 1x5x5内核)
  3. 2nd convolutional feature map 28x28 (3@3x5x5 kernel) 第二个卷积特征图28x28(3 @ 3x5x5内核)
  4. 1st max pooling output 14x14 1st最大池输出14x14
  5. 3rd convolutional feature map 10x10 (3@3x5x5 kernel) 第三卷积特征图10x10(3 @ 3x5x5内核)
  6. 2nd max pooling output 5x5 第二个最大池输出5x5
  7. Flatten 展平
  8. Fully connected layer 75 nodes 完全连接的第75层节点
  9. Fully connected layer 10 nodes 完全连接的第10层节点
  10. Fully connected layer 2 nodes 全连接的第2层节点
  11. Output 产量

Activation functions are said to be of type relu. 激活功能被称为relu类型。

I came up with the following code in keras to replicate the architecture: 我在keras中提出了以下代码来复制体系结构:

model = Sequential()
model.add(Dense(36, input_shape=(36,36,1)))
model.add(BatchNormalization())
model.add(Activation('relu'))
model.add(Conv2D(32, (5, 5)))
model.add(Activation('relu'))
model.add(Conv2D(32, (5, 5)))
model.add(Activation('relu'))
model.add(Conv2D(32, (5, 5)))
model.add(Activation('relu'))

model.add(Conv2D(28, (5, 5)))
model.add(Activation('relu'))
model.add(Conv2D(28, (5, 5)))
model.add(Activation('relu'))
model.add(Conv2D(28, (5, 5)))
model.add(Activation('relu'))


model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(10, (5, 5),padding="same"))
model.add(Activation('relu'))
model.add(Conv2D(10, (5, 5),padding="same"))
model.add(Activation('relu'))
model.add(Conv2D(10, (5, 5),padding="same"))
model.add(Activation('relu'))

model.add(MaxPooling2D(pool_size=(2, 2),padding="same"))


model.add(Flatten())  # this converts our 3D feature maps to 1D feature vectors
model.add(Dense(75))
model.add(Activation('relu'))
model.add(Dense(10))
model.add(Activation('relu'))
model.add(Dense(2))
model.add(Activation('softmax'))


model.compile(Adam(lr=.01), loss='categorical_crossentropy', metrics=['acc'])

However, I am not sure how to understand the kernel notation given for the convolutional feature maps. 但是,我不确定如何理解卷积特征图的内核符号。 To be more specific, I do not understand why there are 3 dimensions (ie 3@ 1x5x5 ) given whereas I can only define a tuple as the "kernel_size" in my Keras model. 更具体地说,我不明白为什么要给出3个维度(即3 @ 1x5x5 ),而我只能在Keras模型中将元组定义为“ kernel_size”。

It would be easier if you attached the paper, but from what we have, it should be as following: 如果您附上纸张,会更容易,但是从我们现有的角度来看,应如下所示:

3@1x5x5 means kernel size is 5-by-5, 1 is the number of channels of the input, 3 is the number of channels of the output. 3 @ 1x5x5表示内核大小为5×5,1是输入的通道数,3是输出的通道数。

I have not used Keras, but it should look like: 我没有使用过Keras,但它看起来应该像这样:

model = Sequential() 
model.add(BatchNormalization(input_shape=(36,36)))  
model.add(Conv2D(3, (5, 5), activation='relu'))
model.add(Conv2D(3, (5, 5), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(3, (5, 5), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))   

model.add(Flatten())  # this converts our 3D feature maps to 1D feature vectors 
model.add(Dense(75, activation= 'relu')) 
model.add(Dense(10, activation= 'relu')) 
model.add(Dense(2, activation= 'softmax'))

model.compile(Adam(lr=.01), loss='categorical_crossentropy', metrics=['accuracy'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM