本文簡要介紹python語言中 torchvision.ops.deform_conv2d
的用法。
用法:
torchvision.ops.deform_conv2d(input: torch.Tensor, offset: torch.Tensor, weight: torch.Tensor, bias: Optional[torch.Tensor] = None, stride: Tuple[int, int] =(1, 1), padding: Tuple[int, int] =(0, 0), dilation: Tuple[int, int] =(1, 1), mask: Optional[torch.Tensor] = None) → torch.Tensor
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 //組,kernel_height,kernel_width]) - 卷積權重,分為大小組 (in_channels //組)
bias(Tensor[out_channels]) -可選的形狀偏差(out_channels,)。默認值:無
mask(Tensor[batch_size,offset_groups * kernel_height * kernel_width,out_height,out_width]) - 應用於卷積核中每個位置的掩碼。默認值:無
卷積的結果
張量[batch_sz, out_channels, out_h, out_w]
如果
mask
不是None
,則執行 Deformable ConvNets v2: More Deformable, Better Results 中說明的可變形卷積 v2;如果mask
是None
,則執行 Deformable Convolutional Networks 中說明的可變形卷積。- 例子::
>>> 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])
參數:
返回:
返回類型:
相關用法
- Python PyTorch detect_anomaly用法及代碼示例
- Python PyTorch deg2rad用法及代碼示例
- Python PyTorch det用法及代碼示例
- Python PyTorch diag用法及代碼示例
- Python PyTorch dirac_用法及代碼示例
- Python PyTorch download_url_to_file用法及代碼示例
- Python PyTorch download_from_url用法及代碼示例
- Python PyTorch dot用法及代碼示例
- Python PyTorch diag_embed用法及代碼示例
- Python PyTorch diff用法及代碼示例
- Python PyTorch diagflat用法及代碼示例
- Python PyTorch dsplit用法及代碼示例
- Python PyTorch div用法及代碼示例
- Python PyTorch diagonal用法及代碼示例
- Python PyTorch dist用法及代碼示例
- Python PyTorch dstack用法及代碼示例
- Python PyTorch digamma用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torchvision.ops.deform_conv2d。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。