tensorflow点滴(1)
来源:互联网 发布:免费域名备案 编辑:程序博客网 时间:2024/06/05 22:22
tf.nn.max_pool中padding的2种形式'SAME','VALID'的差别
import tensorflow as tf
import numpy as np
a= np.random.randint(9,size=(1,9,9,1))
print(np.squeeze(a))
cons = tf.constant(value=a,dtype=tf.float32,shape=(1,9,9,1))
X = tf.nn.max_pool(cons, [1,2,2,1], [1,2,2,1], padding='SAME')
Y= tf.nn.max_pool(cons, [1,2,2,1], [1,2,2,1], padding='VALID')
with tf.Session() as sess:
print('X is following:')
print(np.squeeze(np.array(sess.run(X))))
print('Y is following:')
print(np.squeeze(np.array(sess.run(Y))))
输出结果:
[[4 2 6 1 6 1 2 7 2]
[3 1 2 0 5 3 2 2 6]
[4 4 2 4 5 8 8 4 6]
[4 6 6 8 8 6 0 3 0]
[4 0 8 1 8 3 8 8 0]
[0 5 2 6 4 3 7 8 5]
[6 6 6 4 5 6 0 8 2]
[0 1 1 7 4 7 5 3 3]
[6 0 1 4 5 8 3 5 7]]
X is following:
[[ 4. 6. 6. 7. 6.]
[ 6. 8. 8. 8. 6.]
[ 5. 8. 8. 8. 5.]
[ 6. 7. 7. 8. 3.]
[ 6. 4. 8. 5. 7.]]
Y is following:
[[ 4. 6. 6. 7.]
[ 6. 8. 8. 8.]
[ 5. 8. 8. 8.]
[ 6. 7. 7. 8.]]
import tensorflow as tf
import numpy as np
a= np.random.randint(9,size=(1,9,9,1))
print(np.squeeze(a))
cons = tf.constant(value=a,dtype=tf.float32,shape=(1,9,9,1))
X = tf.nn.max_pool(cons, [1,2,2,1], [1,2,2,1], padding='SAME')
Y= tf.nn.max_pool(cons, [1,2,2,1], [1,2,2,1], padding='VALID')
with tf.Session() as sess:
print('X is following:')
print(np.squeeze(np.array(sess.run(X))))
print('Y is following:')
print(np.squeeze(np.array(sess.run(Y))))
输出结果:
[[4 2 6 1 6 1 2 7 2]
[3 1 2 0 5 3 2 2 6]
[4 4 2 4 5 8 8 4 6]
[4 6 6 8 8 6 0 3 0]
[4 0 8 1 8 3 8 8 0]
[0 5 2 6 4 3 7 8 5]
[6 6 6 4 5 6 0 8 2]
[0 1 1 7 4 7 5 3 3]
[6 0 1 4 5 8 3 5 7]]
X is following:
[[ 4. 6. 6. 7. 6.]
[ 6. 8. 8. 8. 6.]
[ 5. 8. 8. 8. 5.]
[ 6. 7. 7. 8. 3.]
[ 6. 4. 8. 5. 7.]]
Y is following:
[[ 4. 6. 6. 7.]
[ 6. 8. 8. 8.]
[ 5. 8. 8. 8.]
[ 6. 7. 7. 8.]]
阅读全文
0 0
- tensorflow点滴(1)
- 实习点滴(5)--Tensorflow文档学习
- 点滴1
- 点滴1
- WinForm DataGrid 点滴(1
- 点滴英语-1
- 点滴积累(1)
- GNUMake点滴(1)
- Spring 2.0 点滴 (1)
- CSS用法点滴1
- C#点滴1
- 点滴积累1
- 软件职业点滴 1
- websphere5.1使用点滴
- J2me 点滴1
- 知识点滴录1
- Make点滴学习-----1
- 点滴经验--1
- 按enter键调用登陆按钮
- HDU6127-Hard challenge
- Number Sequence
- 算法题练习系列之(二十六): 旧键盘打字
- hduoj1285确定比赛名次(拓扑排序模板)
- tensorflow点滴(1)
- camel读取配置信息
- 大区间内素数(数论)
- 上周热点回顾(8.7-8.13)
- G
- Boolan STL与泛型编程 第一周笔记
- c++ primer plus阅读笔记8---decltype
- linux使用cifs方式mount(挂载)Windows7共享文件
- 17暑假多校联赛7.11 HDU 6130 Kolakoski