文章目录
卷积层
tensorflow提供了tf.nn.conv2d()和tf.nn.bias_add()函数来创建卷积层
下面示例用tf.nn.conv2d()函数来创建一个卷积层
# Output depth
k_output = 64
# Image Properties
image_width = 10
image_height = 10
color_channels = 3
# Convolution filter
filter_size_width = 5
filter_size_height = 5
# Input/Image
input = tf.placeholder(
tf.float32,
shape=[None, image_height, image_width, color_channels])
# Weight and bias
weight = tf.Variable(tf.truncated_normal(
[filter_size_height, filter_size_width, color_channels, k_output]))
bias = tf.Variable(tf.zeros(k_output))
# Apply Convolution
conv_layer = tf.nn.conv2d(input=input,
filter=weights,
strides=[1, 2, 2, 1],
padding='SAME')
# Add bias
conv_layer = tf.nn.bias_add(conv_layer, bias)
# Apply activation function
conv_layer = tf.nn.relu(conv_layer)
weights作为滤波器,[1, 2, 2, 1]作为strides。TensorFlow 对每一个 input 维度使用一个单独

本文介绍了在TensorFlow中如何使用tf.nn.conv2d()创建卷积层,详细解释了滤波器、步长的概念,并通过示例说明了如何设置参数。接着,讨论了最大池化层,重点讲解了tf.nn.max_pool()函数的应用,包括滤波器大小、步长的选择,以及计算输出尺寸的方法。
最低0.47元/天 解锁文章
1129

被折叠的 条评论
为什么被折叠?



