首页 > 其他 > 详细

keras中Convolution1D的使用

时间:2020-04-09 19:38:51      阅读:70      评论:0      收藏:0      [点我收藏+]

keras中Convolution1D的使用

这篇文章主要说明两个东西,一个是Convolution1D的介绍,另一个是model.summary()的使用。

首先我先说下model.summary(),此方法可以打印出模型的信息,读者可以查看每层输出内容。

接下来就说下Convolution1D的使用了,Convolution1D一维卷积,主要用于过滤一维输入的相邻元素,官方文档是这样的

keras.layers.convolutional.Convolution1D(nb_filter, filter_length, init=‘glorot_uniform‘, activation=None, 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)

然后官方给出的事例是这样的

# 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)

然后用print(model.summary())输出是这样的:

技术分享图片

 

   下面我就围绕着上面代码简单介绍下:当把该层作为首层时,需要说明 input_shape

input_shape=(10, 32)简而言之就是10个32维的向量了,nb_filter : 卷积核的数量,也是输出的维度。filter_length : 每个过滤器的长度。
首先我们先看第一个卷积层,输出shape很容易理解,因为有64个卷积核,所以输出也就是64,接下来我们看下参数:其实可以这么理解,我们把例子中(10,32)的信号进行1D卷积相当于对其进行卷积核为(filter_length, 32)的2D卷积

技术分享图片

好了,就酱吧


转载于:https://www.cnblogs.com/qianboping/p/6516639.html

 

keras中Convolution1D的使用

原文:https://www.cnblogs.com/zb-ml/p/12668950.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!