其他分享
首页 > 其他分享> > TensorFlow基础笔记(11) max_pool2D函数 深度学习

TensorFlow基础笔记(11) max_pool2D函数 深度学习

作者:互联网

复制代码
# def max_pool2d(inputs,
#                kernel_size,
#                stride=2,
#                padding='VALID',
#                data_format=DATA_FORMAT_NHWC,
#                outputs_collections=None,
#                scope=None):

#"VALID"模式下
#输出图像大小 out_height = round((in_height - floor(filter_height / 2) * 2) / strides_height) floor表示下取整 round表示四舍五入

input = tf.Variable(tf.round(10 * tf.random_normal([1, 7, 7, 1])))
#filter = tf.Variable(tf.round(5 * tf.random_normal([3, 3, 1, 1])))
#op2 = tf.nn.conv2d(input, filter, strides=[1, 1, 1, 1], padding=‘VALID’)
slim_max_pool2d = slim.max_pool2d(input, [3, 3], [1, 1], scope=‘pool1’)
#slim_conv2d_SAME = slim.conv2d(input, 1, [3, 3], [1, 1], weights_initializer=tf.ones_initializer, padding=‘SAME’)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
slim_max_pool2d_value =
sess.run(slim_max_pool2d)
print(slim_max_pool2d_value.shape)

复制代码 ![在这里插入图片描述](https://www.icode9.com/i/ll/?i=20200227165904459.jpg) kyle1314608 发布了258 篇原创文章 · 获赞 7 · 访问量 2万+ 私信 关注

标签:11,pool2D,max,slim,height,pool2d,tf,round
来源: https://blog.csdn.net/kyle1314608/article/details/104539837