tensorflow随笔-tf.nn.conv2d卷积运算(1)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010255642/article/details/82927146
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  2 13:23:27 2018

@author: myhaspl
@email:[email protected]
tf.nn.conv2d
"""

import tensorflow as tf

g=tf.Graph()

with g.as_default():
    x=tf.constant([
            [[[3.]]
            ]])
    kernel=tf.constant([[[[2.]]]])
    y=tf.nn.conv2d(x,kernel,strides=[1,1,1,1],padding="SAME")

with tf.Session(graph=g) as sess:
    print sess.run(x)
    print sess.run(kernel)

    print x.get_shape()
    print kernel.get_shape()
    
    print sess.run(y)
[[[[3.]]]]
[[[[2.]]]]
(1, 1, 1, 1)
(1, 1, 1, 1)
[[[[6.]]]]

猜你喜欢

转载自blog.csdn.net/u010255642/article/details/82927146