快捷方式

deform_conv2d

torchvision.ops.deform_conv2d(input: Tensor, offset: Tensor, weight: Tensor, bias: Optional[Tensor] = None, stride: Tuple[int, int] = (1, 1), padding: Tuple[int, int] = (0, 0), dilation: Tuple[int, int] = (1, 1), mask: Optional[Tensor] = None) Tensor[源代码]

执行可变形卷积 v2,如 可变形卷积网络 v2:更可变形,更好的结果 中所述,如果 mask 不是 None,并且执行可变形卷积,如 可变形卷积网络 中所述,如果 maskNone

参数:
  • input (Tensor[batch_size, in_channels, in_height, in_width]) – 输入张量

  • offset (Tensor[batch_size, 2 * offset_groups * kernel_height * kernel_width, out_height, out_width]) – 用于卷积核中每个位置的偏移量。

  • weight (Tensor[out_channels, in_channels // groups, kernel_height, kernel_width]) – 卷积权重,分成大小为 (in_channels // groups) 的组

  • bias (Tensor[out_channels]) – 形状为 (out_channels,) 的可选偏差。默认值:None

  • stride (intTuple[int, int]) – 卷积中心之间的距离。默认值:1

  • padding (intTuple[int, int]) – 每个图像周围填充的零的高度/宽度。默认值:0

  • dilation (intTuple[int, int]) – 核元素之间的间距。默认值:1

  • mask (Tensor[batch_size, offset_groups * kernel_height * kernel_width, out_height, out_width]) – 用于卷积核中每个位置的掩码。默认值:None

返回:

卷积的结果

返回类型:

Tensor[batch_sz, out_channels, out_h, out_w]

示例:
>>> input = torch.rand(4, 3, 10, 10)
>>> kh, kw = 3, 3
>>> weight = torch.rand(5, 3, kh, kw)
>>> # offset and mask should have the same spatial size as the output
>>> # of the convolution. In this case, for an input of 10, stride of 1
>>> # and kernel size of 3, without padding, the output size is 8
>>> offset = torch.rand(4, 2 * kh * kw, 8, 8)
>>> mask = torch.rand(4, kh * kw, 8, 8)
>>> out = deform_conv2d(input, offset, weight, mask=mask)
>>> print(out.shape)
>>> # returns
>>>  torch.Size([4, 5, 8, 8])

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并获得问题的解答

查看资源