ConvolutionLayer *AddConvolution(Tensor *input, int32_t numOutputMap, Dims kernelHW, WeightsBuf weights, WeightsBuf bias) noexcept;
函数功能
向网络添加一个卷积层。
函数原型
ConvolutionLayer *AddConvolution(Tensor *input, int32_t numOutputMap, Dims kernelHW, WeightsBuf weights, WeightsBuf bias) noexcept;
约束说明
- input不可以为空,数据类型必须是NCHW,维度为4维,每一维都需要大于0,且H维度取值范围在[1, 100000],W维度取值范围在[1, 4096]。
- numOutputMap取值范围在[1, 4096]。
- kernelHW不可以为空,维度为2维,每一维都范围是[1, 255]。
- weights不可以为空,weights的value不可以为空,weights的count不可以是0。weights的count需要满足公式weights.count = numOutputMap * (input -> GetDimensions() [1] / groupNum) * kernelHW[0] * kernelHW[1]。
- 如果bias不为空,bias的count需要与numOutputMap相同。
- 当前不支持动态shape。
参数说明
参数名 |
输入/输出 |
说明 |
---|---|---|
input |
输入 |
卷积的输入张量。 |
numOutputMap |
输入 |
卷积的输出特征图的数量。 |
kernelHW |
输入 |
卷积核的HW维度。 |
weights |
输入 |
卷积核的权重。 |
bias |
输入 |
卷积的偏置权重。WeightsBuf{}表示没有偏置。 |
返回值说明
返回新的卷积层,如果添加失败时返回nullptr。
父主题: class Network