This layer uses different filters to find attributes of the data that affects the result. As an example there could be a filter to find horizontal edges in an image.
@author Daniel Persson (mailto.woden@gmail.com)
This layer uses different filters to find attributes of the data that affects the result. As an example there could be a filter to find horizontal edges in an image.
@author Daniel Persson (mailto.woden@gmail.com)
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| .ctor | 2 | Creates an empty layer, used by the deserializer. |
| forward | 1 | Runs the convolution of the input with every filter and adds the per filter bias. |
| PackFilters | 1 | 把各个输出通道的卷积核打包成一个 (KH, KW, C, OutC) 的后端张量。 |
| UnpackFilterGradients | 1 | 把后端算出的 (KH, KW, C, OutC) 卷积核梯度累加回各个 ConvolutionLayer.filters(d) 的 dw。 |
| backward | 1 | Computes the gradients with respect to the filters, the biases and the input of this layer. |
| ToString | 1 | Returns a short description of this layer. |
03 Properties
| Name | Overloads | Summary |
|---|---|---|
| BackPropagationResult | 1 | Gets the filter and bias parameter blocks of this layer. |
| Type | 1 | Gets the kind of this layer, always LayerTypes.Convolution. |
04 Fields
| Name | Overloads | Summary |
|---|---|---|
| filtersPacked | 1 | 最近一次前向传播时按后端布局打包好的卷积核张量, 形状 (KH, KW, C, OutC)。 |
05 Members
Creates an empty layer, used by the deserializer.
Creates a convolution layer and derives the output size from the input size, the filter size and the padding.
| Name | Type | Description |
|---|---|---|
def | OutputDefinition | The shared output definition that carries the input size. |
sx | Int32 | Side length of the square filter window. |
filters | Int32 | Number of filters, i.e. the number of output channels. |
stride | Int32 | Sliding stride of the filter window. |
padding | Int32 | Zero padding applied around the input. |
Boolean)Runs the convolution of the input with every filter and adds the per filter bias.
| Name | Type | Description |
|---|---|---|
db | DataBlock | The input data block. |
training | Boolean | Ignored; the convolution layer behaves the same in both modes. |
The output feature maps.
把各个输出通道的卷积核打包成一个 (KH, KW, C, OutC) 的后端张量。
每个 ConvolutionLayer.filters(d) 的内部布局是 (KH, KW, C), 而后端要求输出通道作为最末轴, 因此需要一次带跨步的重新排布, 不能简单地整块拷贝。
Tensor)把后端算出的 (KH, KW, C, OutC) 卷积核梯度累加回各个 ConvolutionLayer.filters(d) 的 dw。
这里必须累加而不是直接赋值: 参数梯度是在一个 mini-batch 之内跨样本累加的 (TrainerAlgorithm.train 每 batch_size 个样本才调用一次 adjustWeights, 且只有在那里才把 g(j) 清零), 如果直接赋值就会丢掉同一批内前面样本的贡献, 等效学习率被缩小 batch_size 倍。
Computes the gradients with respect to the filters, the biases and the input of this layer.
Returns a short description of this layer.
The constant text conv().
Gets the filter and bias parameter blocks of this layer.
Gets the kind of this layer, always LayerTypes.Convolution.
最近一次前向传播时按后端布局打包好的卷积核张量, 形状 (KH, KW, C, OutC)。
反向传播需要把它作为 Conv2DBackwardInput 的输入(计算对输入的梯度要用到前向的卷积核), 所以在每次前向时缓存下来; 由于卷积核在训练过程中一直被就地更新, 这里每次都重新打包, 因此不存在缓存过期的问题。