tensorflow 通过 tf.nn.conv2d 实现基本的卷积运算.
我对“strides”参数特别感兴趣,它可以让您设置卷积滤波器的步幅——每次将滤波器在图像上移动多远。
one of the early tutorials 中给出的示例,每个方向的图像步长为 1,为
def conv2d(x, W):
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
链接文档中对步幅数组进行了更多解释:
In detail, with the default NHWC format...
Must have strides[0] = strides[3] = 1. For the most common case of the same horizontal and vertices strides, strides = [1, stride, stride, 1].
请注意,“步幅”的顺序与输入的顺序相匹配:NHWC 格式中的[批处理、高度、宽度、 channel ]
。
显然,batch
和 channels
的步长不为 1 是没有意义的,对吗? (您的过滤器应始终遍历每个批处理和每个 channel )
但是为什么可以选择在 strides[0]
和 strides[3]
中放入 1 以外的值呢? (它是一个“选项”,因为您可以在传入的 python 数组中放入除 1 之外的其他内容,忽略上面的文档引用)
是否存在一种情况,我会在batch
或channels
维度上迈出非一步,例如
tf.nn.conv2d(x, W, strides=[2, 1, 1, 2], padding='SAME')
如果是这样,这个例子对于卷积运算意味着什么?
最佳答案
在某些情况下,您可能会分块发送视频。这意味着您的批处理将是一系列帧。假设接近的帧应该非常相似,我们可以通过增加批量步幅来省略其中的一些帧。据我了解。不过,我不知道 channel 跨度
关于tensorflow - 我什么时候想要为 TensorFlow 卷积设置批量或 channel 维度的步幅?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46386211/