TensorFlow备忘录——conv2d函数

TensorFlow学习备忘录

tf.nn.conv2d(input, filter, strides, padding, use_cudnn_on_gpu=None, data_format=None, name=None)

Args

  • input: A 4-D Tensor。 需要计算卷积的图像,其shape是[batch, height, width, channels]。Tensor shape可以由data_format设定。Type必须是"half", "float32","float64"之一。
  • filter: A 4-D Tensor。 卷积核。 Type和input相同。Shape是[卷积核高度,卷积核宽度, 图像通道数, 卷积核个数]。
  • strides: 1-D Tensor of length 4。步长。Shape和input相同,一般batch和channels恒定为1,即[1, height, weight, 1]
  • padding: 卷积方式。可选方法有"SAME""VALID"。其中,VALID方式以(1,1)作为卷积的左上角起始点。SAME则以(1,1)作为卷积的中心起始点。即,SAME方法得到的卷积矩阵要大于VALID。
  • use_cudnn_on_gpu: 是否使用GPU加速。默认为True。
  • data_format: 数据格式,支持的格式有"NHWC""NCHW"。其中的区别主要是channels参数的位置。一般使用默认即可。
  • name: 用以指定该操作的name。在TensorBoard展示中较为有用。

Returns

A Tensor。卷积操作后的特征图。