您当前的位置: 首页 >  tensorflow

星夜孤帆

暂无认证

  • 3浏览

    0关注

    626博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Tensorflow一维卷积用法

星夜孤帆 发布时间:2018-06-12 10:00:11 ,浏览量:3

import tensorflow as tf
import numpy as np
input = tf.constant(1,shape=(64,10,1),dtype=tf.float32,name='input')#shape=(batch,in_width,in_channels)
w = tf.constant(3,shape=(3,1,32),dtype=tf.float32,name='w')#shape=(filter_width,in_channels,out_channels)
conv1 = tf.nn.conv1d(input,w,2,'VALID') #2为步长
print(conv1.shape)#宽度计算(width-kernel_size+1)/strides ,(10-3+1)/2=4  (64,4,32)
conv2 = tf.nn.conv1d(input,w,2,'SAME') #步长为2
print(conv2.shape)#宽度计算width/strides  10/2=5  (64,5,32)
conv3 = tf.nn.conv1d(input,w,1,'SAME') #步长为1
print(conv3.shape)  # (64,10,32)
with tf.Session() as sess:
    print(sess.run(conv1))
    print(sess.run(conv2))
    print(sess.run(conv3))

以下是input_shape=(1,10,1), w = (3,1,1)时,conv1的shape

以下是input_shape=(1,10,1), w = (3,1,3)时,conv1的shape

关注
打赏
1636984416
查看更多评论
立即登录/注册

微信扫码登录

0.0380s