简体   繁体   English

如何在TensorFlow的conv2d中跨越多个频道?

[英]How to stride over multiple channels in conv2d of TensorFlow?

I have a RGB colour image, which i was trying to train using conv2d. 我有一个RGB彩色图像,我试图用conv2d训练。 As per CNN each filter should stride over all channels of input. 根据CNN,每个滤波器应跨越所有输入通道。 But while following this rule in TF i got an error 但是在TF中遵循这条规则时我遇到了错误

InvalidArgumentError: Current implementation does not yet support strides in the batch and depth dimensions.

From this discussion, it seems TF supports only one increment along input channels in conv2d. 这个讨论来看,TF似乎只支持conv2d中输入通道的一个增量。 So my question is 所以我的问题是
1. Is there any way i could stride over multiple channels in TF ? 1.有什么方法可以在TF中跨过多个频道吗?
2. will it be a correct procedure to use default stride(ie 1) over RGB Image? 2.对RGB图像使用默认步幅(即1)是否正确?

In my opinion, it isn't useful to stride over batch or depth . 在我看来,跨越批量深度是没有用的。 Your stride should be something like [1,m,n,1]. 你的步伐应该是[1,m,n,1]。

First, let's start with batch , the 1st dimension. 首先,让我们从第一个维度批处理开始。 These are your samples, your images. 这些是您的样本,您的图像。 Striding over your images would mean you'd just drop whole images from training or induction. 跨过您的图像意味着您只需从训练或感应中删除整个图像。

Second, depth the 4th dimension. 第二, 深入第四维度。 Initially this is your RGB. 最初这是你的RGB。 Striding across RGB would mean that you'd just completely drop a whole color or two. 跨越RGB将意味着您只需完全丢弃一两种颜色。 That doesn't make sense. 这没有意义。 It would be massive information loss. 这将是大量的信息丢失。

Third, the purpose of stride. 三,迈向步伐的目的。 Stride can useful when your image is an oversampling at the pixel level (not the color level) of what you are analyzing and you are okay with just tossing information. 当您的图像是您正在分析的像素级别(而不是颜色级别)的过采样时,步幅可能很有用,只需抛掷信息就可以了。 It is aggressive data destruction. 这是积极的数据破坏。 It turns high definition images into medium definition, and medium definition into low. 它将高清图像转换为中等清晰度,将中等清晰度转换为低清晰度。

You wouldn't want to destroy RBG channels ( depth ) or whole images ( batch ) even if you want to downsample your images ( stride ). 即使您想对图像进行下采样( 步幅 ),也不希望破坏RBG通道( 深度 )或整个图像( 批量 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM