def get_cnn_network():
print('configure cnn network')
nbfilter = 102
model = Sequential()
model.add(Convolution1D(input_dim=4,input_length=107,
nb_filter=nbfilter,
filter_length=7,
border_mode="valid",
activation="relu",
subsample_length=1))
#dim 维度 length 序列长度
#input_dim: Number of channels/dimensions in the input. Either this argument or the keyword argument input_shapemust be provided when using this layer as the first layer in a model.
#input_length: Length of input sequences, when it is constant. This argument is required if you are going to connect Flatten then Dense layers upstream (without it, the shape of the dense outputs cannot be computed).
model.add(MaxPooling1D(pool_length=3))
#https://www.cnblogs.com/bzjia-blog/p/3415790.html 池化:特征图像区域的一部分求个均值或者最大值,用来代表这部分区域。如果是求均值就是mean pooling,求最大值就是max pooling
model.add(Dropout(0.5))
#为输入数据施加Dropout。Dropout将在训练过程中每次更新参数时按一定概率(rate)随机断开输入神经元,Dropout层用于防止过拟合。
#参数 rate:0~1的浮点数,控制需要断开的神经元的比例
model.add(Flatten())
#Flatten层用来将输入“压平”,即把多维的输入一维化,常用在从卷积层到全连接层的过渡。Flatten不影响batch的大小。
model.add(Dense(nbfilter, activation='relu'))
#Flatten层用来将输入“压平”,即把多维的输入一维化,常用在从卷积层到全连接层的过渡。Flatten不影响batch的大小。
model.add(Dropout(0.25))
return model
Keras 卷积层Convolutional
最新推荐文章于 2023-08-29 16:08:36 发布