x_raw=np.array([
[2,5,3],
[3,4,2],
[41,1,1]
)
f_raw=np.数组(
[[
[2,1],
[3,4]
]
[4,1],
[1,2]
])
f=tf.常量(f_raw,dtype=tf.float32)
x=tf.常量(x_raw,dtype=tf.float32)
滤波器=tf.整形(f,[2,2,1,2])
图像=tf.重塑(x,[1,3,3,1])
tf.nn.conv2d(图像,过滤器,[1,1,1,1],“有效”).eval()
< /代码>
但是TensorFlow的输出是关闭的:
< Buff行情>
数组([[[35.,33.],[37.,25.],[[35.,25.],[19.,15.]]],dtype=float32)
< /块引用>
我做错了什么?
我想用TensorFlow重现同样的结果tf.nn.conv2d:
x_raw = np.array([
[2,5,3],
[3,4,2],
[4,1,1]
])
f_raw = np.array(
[[
[2,1],
[3,4]
],[
[4,1],
[1,2]
]])
f = tf.constant(f_raw, dtype=tf.float32)
x = tf.constant(x_raw, dtype=tf.float32)
filter = tf.reshape(f, [2, 2, 1, 2])
image = tf.reshape(x, [1, 3, 3, 1])
tf.nn.conv2d(image, filter, [1, 1, 1, 1], "VALID").eval()
但是TensorFlow的输出是关闭的:
数组([[[35.,33.],[37.,25.],[[35.,25.],[19.,15.]]],dtype=float32)
我做错了什么?