# for image: number of images x height x width x channels # for filter: height x width x channels x number of filters input = tf.Variable(tf.random_normal([1,3,3,5])) filter = tf.Variable(tf.random_normal([1,1,5,1])) op = tf.nn.conv2d(input, filter, strides=[1,1,1,1], padding='VALID') # the resulting image will be a 3x3 with 1 channel (size 1x3x3x1),where the value of # each pixel is the dot product across channels of the filter with the corresponding pixel # in the input image stride = [1,1,1,1] # the first dimension of the input is the number of images # ..... # .xxx. # .xxx. # .xxx. # ..... stride = [1,2,2,1] # x.x.x # ..... # x.x.x # ..... # x.x.x input = tf.Variable(tf.random_normal([10,5,5,5])) filter = tf.Variable(tf.random_normal([3,3,5,7])) op = tf.nn.conv2d(input, filter, strides=[1, 2, 2, 1], padding='SAME') #result: size 10x3x3x7
详细解释见:
https://stackoverflow.com/questions/34619177/what-does-tf-nn-conv2d-do-in-tensorflow