当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python mxnet.ndarray.contrib.ModulatedDeformableConvolution用法及代码示例


用法:

mxnet.ndarray.contrib.ModulatedDeformableConvolution(data=None, offset=None, mask=None, weight=None, bias=None, kernel=_Null, stride=_Null, dilate=_Null, pad=_Null, num_filter=_Null, num_group=_Null, num_deformable_group=_Null, workspace=_Null, no_bias=_Null, im2col_step=_Null, layout=_Null, out=None, name=None, **kwargs)

参数

  • data(NDArray) - 输入数据到ModulatedDeformableConvolutionOp
  • offset(NDArray) - 输入偏移量到ModulatedDeformableConvolutionOp
  • mask(NDArray) - ModulatedDeformableConvolutionOp 的输入掩码
  • weight(NDArray) - 权重矩阵。
  • bias(NDArray) - 偏置参数。
  • kernel(Shape(tuple), required) - 卷积核大小:(h, w) 或 (d, h, w)
  • stride(Shape(tuple), optional, default=[]) - 卷积步幅:(h, w) 或 (d, h, w)。每个维度默认为 1。
  • dilate(Shape(tuple), optional, default=[]) - 卷积膨胀:(h, w) 或 (d, h, w)。每个维度默认为 1。
  • pad(Shape(tuple), optional, default=[]) - 卷积的零填充:(h, w) 或 (d, h, w)。默认为无填充。
  • num_filter(int (non-negative), required) - 卷积滤波器(通道)编号
  • num_group(int (non-negative), optional, default=1) - 组分区数。
  • num_deformable_group(int (non-negative), optional, default=1) - 可变形组分区的数量。
  • workspace(long (non-negative), optional, default=1024) - 卷积允许的最大温度工作空间 (MB)。
  • no_bias(boolean, optional, default=0) - 是否禁用偏差参数。
  • im2col_step(int (non-negative), optional, default=64) - 每个 im2col 计算的最大图像数;总批大小应可被此值整除或小于此值;如果您遇到内存不足的问题,可以尝试在此处使用较小的值。
  • layout({None, 'NCDHW', 'NCHW', 'NCW'},optional, default='None') - 设置输入、输出和权重的布局。默认布局为空:NCW 表示 1d,NCHW 表示 2d,NCDHW 表示 3d。
  • out(NDArray, optional) - 输出 NDArray 来保存结果。

返回

out- 此函数的输出。

返回类型

NDArray 或 NDArray 列表

在 4-D 输入上计算 2-D 调制可变形卷积。

https://arxiv.org/abs/1811.11168中说明了调制的可变形卷积操作

对于二维调制可变形卷积,形状为

  • data(batch_size, channel, height, width)
  • offset(batch_size, num_deformable_group * kernel[0] * kernel[1] * 2, height, width)
  • mask(batch_size, num_deformable_group * kernel[0] * kernel[1], height, width)
  • weight(num_filter, channel, kernel[0], kernel[1])
  • bias(num_filter,)
  • out(batch_size, num_filter, out_height, out_width).

定义:

f(x,k,p,s,d) = floor((x+2*p-d*(k-1)-1)/s)+1

那么我们有:

out_height=f(height, kernel[0], pad[0], stride[0], dilate[0])
out_width=f(width, kernel[1], pad[1], stride[1], dilate[1])

如果 no_bias 设置为 true,则忽略 bias 项。

默认数据 layoutNCHW ,即 (batch_size, channle, height, width)

如果 num_group 大于 1,用 g 表示,则将输入 data 沿通道轴均匀拆分为 g 部分,并沿第一维均匀拆分 weight。接下来计算 i -th 数据部分与 i -th 权重部分的卷积。通过连接所有g 结果获得输出。

如果num_deformable_group大于1,记为dg,则将输入offset沿通道轴均匀拆分为dg部分,同时将out沿通道轴均匀拆分为dg部分.接下来计算可变形卷积,将偏移部分的 i -th 部分应用于 i -th out。

weightbias 都是可学习的参数。

相关用法


注:本文由纯净天空筛选整理自apache.org大神的英文原创作品 mxnet.ndarray.contrib.ModulatedDeformableConvolution。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。