tensorflow一维卷积输入_基于Tensorflow一维卷积用法详解

本文详细介绍了Tensorflow中一维卷积的操作,包括不同步长、填充方式的使用,以及conv1d和layers.conv1d函数的示例。通过实例展示了卷积在网络中的应用,并提供了不同核尺寸卷积和池化操作的代码示例。
摘要由CSDN通过智能技术生成

我就废话不多说了,大家还是直接看代码吧!

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值