# tensorflow中的tf.nn.conv2d学习

tf.nn.conv2d是TensorFlow里面实现卷积的函数

import tensorflow as tf

input = tf.Variable(tf.random_normal([1,3,3,1]))#1表示一次读几张图片，3*3的图像大小，1表示通道的个数
filter = tf.Variable(tf.random_normal([3,3,1,2]))#3*3表示卷积核的大小，1表示通道的个数，2表示卷积核个数
op = tf.nn.conv2d(input, filter, strides=[1, 1, 1, 1], padding='VALID')
sess = tf.InteractiveSession()
sess.run(tf.global_variables_initializer())
print("input",sess.run(input))
print("filter",sess.run(filter))
print("op",sess.run(op))

"C:\Program Files\Anaconda3\python.exe" D:/pycharmprogram/tensorflow_learn/cnn_learn/conv2d_learn.py
2018-05-15 10:15:13.014600: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2018-05-15 10:15:13.014600: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
input [[[[ 0.3438858 ]
[-0.4425889 ]
[-0.28974482]]

[[-0.82606524]
[ 0.3106512 ]
[ 0.24117461]]

[[ 0.12498179]
[-0.12209705]
[ 0.17391145]]]]
filter [[[[-1.2464828  -0.6758195 ]]

[[ 0.6434889   1.2502667 ]]

[[ 0.44064078  1.5831428 ]]]

[[[ 1.2931986   1.9008949 ]]

[[ 0.04882597 -0.2704289 ]]

[[-0.203322    0.8987799 ]]]

[[[-0.36723176  0.97302365]]

[[ 0.7012152   1.1584816 ]]

[[-0.8887519   0.6498683 ]]]]
op [[[[-2.2293346 -2.5887933]]]]

Process finished with exit code 0


• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120