Tensorflow(1.15.0)卷积操作

这篇博客详细介绍了在Tensorflow 1.15.0中进行卷积操作的具体情况,通过实例展示了不同形状的输入在卷积后的输出效果。例如,一个batch的一张3x3单通道图像经过卷积后变为3x3双通道图像,进一步阐述了卷积操作在深度学习和神经网络中的应用。
摘要由CSDN通过智能技术生成
#-*- codeing = utf-8 -*-
#@Time :2021/5/17 10:33
#@Author :Onion
#@File :Convolution.py
#@Software :PyCharm

# 卷积神经网络Demo
# 步骤
# 1:定义输入变量
# 2:定义卷积核变量
# 3:定义卷积操作
# 4:运行卷积操作

import tensorflow as tf
tf.compat.v1.disable_eager_execution()
tf.compat.v1.disable_v2_behavior()
tf.compat.v1.disable_eager_execution()
tf.compat.v1.reset_default_graph()


# 1:定义输入变量
# shape的参数[batch, in_height, in_width, in_channels] [训练时一个batch的图片数量, 图片高度, 图片宽度, 图像通道数]
# 定义3个输入变量来模拟输入图片,分别是5*5大小1个通道,5*5大小2个通道,4*4大小1个通道的模拟数据
input1 = tf.compat.v1.Variable(tf.compat.v1.constant(1.0,shape=[1,5,5,1]))
input2 = tf.compat.v1.Variable(tf.compat.v1.constant(1.0,shape=[1,5,5,2]))
input3 = tf.compat.v1.Variable(tf.compat.v1.constant(1.0,shape=[1,4,4,1]))
# 2:定义卷积核变量
# shape的参数[filter_height, filter_width, in_channels, out_channels] [卷积核的高度,卷积核的宽度,图像通道数,卷积核个数]
# value以2*2个数据为单元,单元数图像通道数*卷积核个数
filter1 = tf.compat.v1.Variable(tf.compat.v1.constant(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

敲代码的洋葱头

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值