本文介绍了卷积神经网络中的滤波器如何生成多个通道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Tensorflow学习卷积神经网络.

I am learning convolutional neural network with Tensorflow.

对于 tf.nn.conv2d ,我有些疑问.它的参数之一是filter:

我不明白out_channels是什么意思.

假设输入图像是[1, 3, 3, 1].因此,大小为3xx,通道为1.
然后,我们有了一个过滤器[2, 2, 1, 5],这意味着在过滤之后,我们将得到一个具有5个通道的大小为2x2(有效"填充)的图像.

Suppose input image is [1, 3, 3, 1]. So the size is 3xx and the channel is 1.
Then we have a filter [2, 2, 1, 5], which means after the filtering, we will have an image of size 2x2 ("valid" padding) with 5 channels.

5个渠道来自哪里?据我了解,过滤只能生成1个通道. Tensorflow在这里使用5种不同的过滤器功能吗?

Where are the 5 channels from? From my understanding, the filtering can only have 1 channel generated. Is Tensorflow using 5 different filter functions here?

推荐答案

filter参数如您所引用,="nofollow noreferrer"> tf.nn.conv2d 函数是尺寸为[filter_height, filter_width, in_channels, out_channels]的4D张量.此张量表示尺寸为filter_height x filter_widthout_channels滤镜的堆栈,将应用于具有in_channels通道的图像.

The filter argument to the tf.nn.conv2d function, as you quoted, is a 4D tensor of dimensions [filter_height, filter_width, in_channels, out_channels]. This tensor represents a stack of out_channels filters of dimension filter_height x filter_width, to be applied over an image with in_channels channels.

参数filter_heightfilter_widthout_channels由您定义,而input_channels取决于您对tf.nn.conv2d的输入.

The parameters, filter_height, filter_width and out_channels are defined by you, whereas input_channels is dependent on your input to tf.nn.conv2d.

换句话说,尺寸为[2, 2, 1, 5]的滤波器张量表示要在1通道输入上应用的5不同的2 x 2滤波器,但是您可以将其完美地更改为[2, 2, 1, 7]或其他任何值否则会给您带来更好的结果.

In other words, a filter tensor with dimensions [2, 2, 1, 5], represents 5 different 2 x 2 filters to be applied over a 1-channel input, but you could perfectly change it to [2, 2, 1, 7], or whatever else gives you better results.

为进一步说明,在下面的gif中,您有一个[3, 3, 1, 1]张量滤波器,卷积在[1, 5, 5, 1]图像上.这意味着您只将1过滤器卷积在图像上.

To further illustrate, in the following gif you have a [3, 3, 1, 1] tensor filter convolving over a [1, 5, 5, 1] image. This means you have only 1 filter being convolved over the image.

GIF来源

这篇关于卷积神经网络中的滤波器如何生成多个通道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 03:04