[转]Keras读书笔记----卷积层、池化层

1. 卷积层
1.1. Convolution1D层
一维卷积层,用以在一维输入信号上进行邻域滤波。当使用该层作为首层时,需要提供关键字参数 input_dim 或 input_shape 。
keras.layers.convolutional.Convolution1D(nb_filter, filter_length, init='uniform', activation='linear', weights=None, border_mode='valid', subsample_length=1, W_regularizer=None, b_regularizer=None, activity_regularizer=None, W_constraint=None, b_constraint=None, bias=True, input_dim=None, input_length=None)
nb_filter:卷积核的数目(即输出的维度)
filter_length:卷积核的空域或时域长度
init:初始化方法,为预定义初始化方法名的字符串,或用于初始化权重的Theano函数。该参数仅在不传递 weights 参数时有意义。
activation:激活函数,为预定义的激活函数名,或逐元素( element-wise)的Theano函数。如果不指定该参数,将不会使用任何激活函数(即使用线性激活函数: a(x)=x)
weights:权值,为numpy array的list。该list应含有一个形如( input_dim,output_dim)的权重矩阵和一个形如(output_dim,)的偏置向量。
border_mode:边界模式,为“valid”或“same”
subsample_length:输出对输入的下采样因子
W_regularizer:施加在权重上的正则项,为WeightRegularizer对象
b_regularizer:施加在偏置向量上的正则项,为WeightRegularizer对象
activity_regularizer:施加在输出上的正则项,为ActivityRegularizer对象
W_constraints:施加在权重上的约束项,为Constraints对象
b_constraints:施加在偏置上的约束项,为Constraints对象
bias:布尔值,是否包含偏置向量(即层对输入做线性变换还是仿射变换)
input_dim:整数,输入数据的维度。当该层作为网络的第一层时,必须指定该参数或 input_shape 参数。
input_length:当输入序列的长度固定时,该参数为输入序列的长度。当需要在该层后连接 Flatten 层,然后又要连接 Dense 层时,需要指定该参数,否则全连接的输出无法计算出来。
输入shape形如( samples, steps, input_dim)的3D张量
输出shape形如( samples, new_steps, nb_filter)的3D张量,因为有向量填充的原因, steps 的值会改变
# apply a convolution 1d of length 3 to a sequence with 10 timesteps,
# with 64 output filters
model = Sequential()
model.add(Convolution1D(64, 3, border_mode='same', input_shape=(10, 32)))
# now model.output_shape == (None, 10, 64)
# add a new conv1d on top
model.add(Convolution1D(32, 3, border_mode='same'))
# now model.output_shape == (None, 10, 32)

2. 池化层
2.1. MaxPooling1D层
对时域1D信号进行最大值池化
keras.layers.convolutional.MaxPooling1D(pool_length=2, stride=None, border_mode='valid')

pool_length:下采样因子,如取2则将输入下采样到一半长度
stride:整数或None,步长值
border_mode: ‘valid’或者‘same’注意,目前‘same’模式只能在TensorFlow作为后端时使用
输入shape形如( samples, steps, features)的3D张量

输出shape形如( samples, downsampled_steps, features)的3D张量
————————————————
版权声明:本文为CSDN博主「梵天的读书笔记」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/is_badboy/java/article/details/79746182



 

猜你喜欢

转载自www.cnblogs.com/zb-ml/p/12664078.html