keras深度学习模型

21 keras卷积层

2017-06-04  本文已影响121人  readilen

上一篇介绍了基础核心层,就是用来构建普通网络的基础部件。这一篇主要介绍的是卷积层,主要用于构建卷积神经网络等需要用到卷积操作的神经网络。卷积操作(可以参看博文卷积算子计算方法-卷积操作)的优点就是可以增强原信号特征,增强对原信号位移、形变之后的识别能力,有效降低噪音等。而卷积神经网络是目前来说对图像识别的最好工具,因为它可以有效识别有位移、形变等的图像。下面来看下卷基层都有哪些结构。

一、Convolution1D

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, W_constraint=None,  
        b_constraint=None, input_dim=None, input_length=None)

该卷积操作用于过滤一维输入的相邻元素。当把该层作为模型的第一层时,要么给参数input_dim传值(int类型,比如128代表128维的向量),要么给input_shape传值(整数元组,比如(10,128)代表10个128维的向量)。

二、Convolution2D

keras.layers.convolutional.Convolution2D(nb_filter,nb_row, nb_col,  
        init='glorot_uniform', activation='linear', weights=None,  
        border_mode='valid', subsample=(1, 1),  
        W_regularizer=None, b_regularizer=None, W_constraint=None)  

这个是CNN常用的方法。这个卷积操作是通过一个2维窗口的卷积核进行过滤。当把该层当做模型的第一层时,需要提供参数input_shape,比如input_shape=(3, 128, 128)表示128128的RGB(3通道,看以理解成3张128128的图片叠加而成的)图片。
**** inputshape: 4维 tensor(nb_samples, channels,rows, cols)
**** outputshape: 4维 tensor(nb_samples, nb_filter,rows, cols). rows,cols的值可能会随着边缘填充0元素而产生变化。
**** 参数

三、MaxPooling1D类

layers.convolutional.MaxPooling1D(pool_length=2, stride=None, ignore_border=True)  

最大池化操作,也就是常说的下采样。因为这个是对于1维输入进行操作的,因此下采样因子就只有一个长度。
inputshape: 3维 tensor(nb_samples, steps, dim)
outputshape: 3维 tensor(nb_samples,downsampled_steps, dim)
参数:

四、MaxPooling2D类

keras.layers.convolutional.MaxPooling2D(pool_size=(2, 2), ignore_border=True)  

这个下采样的采样因子是2维的。
inputshape: 4维 tensor(nb_samples, stack_size,nb_row, nb_col)
outputshape: 4维 tensor(nb_samples, stack_size,new_nb_row, new_nb_col)
参数:

原文地址

上一篇 下一篇

猜你喜欢

热点阅读