本文整理汇总了Python中torch.nn.functional.conv_transpose3d方法的典型用法代码示例。如果您正苦于以下问题:Python functional.conv_transpose3d方法的具体用法?Python functional.conv_transpose3d怎么用?Python functional.conv_transpose3d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torch.nn.functional
的用法示例。
在下文中一共展示了functional.conv_transpose3d方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: quaternion_transpose_conv
# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import conv_transpose3d [as 别名]
def quaternion_transpose_conv(input, r_weight, i_weight, j_weight, k_weight, bias, stride,
padding, output_padding, groups, dilatation):
"""
Applies a quaternion trasposed convolution to the incoming data:
"""
cat_kernels_4_r = torch.cat([r_weight, -i_weight, -j_weight, -k_weight], dim=1)
cat_kernels_4_i = torch.cat([i_weight, r_weight, -k_weight, j_weight], dim=1)
cat_kernels_4_j = torch.cat([j_weight, k_weight, r_weight, -i_weight], dim=1)
cat_kernels_4_k = torch.cat([k_weight, -j_weight, i_weight, r_weight], dim=1)
cat_kernels_4_quaternion = torch.cat([cat_kernels_4_r, cat_kernels_4_i, cat_kernels_4_j, cat_kernels_4_k], dim=0)
if input.dim() == 3:
convfunc = F.conv_transpose1d
elif input.dim() == 4:
convfunc = F.conv_transpose2d
elif input.dim() == 5:
convfunc = F.conv_transpose3d
else:
raise Exception("The convolutional input is either 3, 4 or 5 dimensions."
" input.dim = " + str(input.dim()))
return convfunc(input, cat_kernels_4_quaternion, bias, stride, padding, output_padding, groups, dilatation)
示例2: quaternion_transpose_conv
# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import conv_transpose3d [as 别名]
def quaternion_transpose_conv(input, r_weight, i_weight, j_weight, k_weight, bias, stride,
padding, output_padding, groups, dilatation):
"""
Applies a quaternion trasposed convolution to the incoming data:
"""
cat_kernels_4_r = torch.cat([r_weight, -i_weight, -j_weight, -k_weight], dim=1)
cat_kernels_4_i = torch.cat([i_weight, r_weight, -k_weight, j_weight], dim=1)
cat_kernels_4_j = torch.cat([j_weight, k_weight, r_weight, -i_weight], dim=1)
cat_kernels_4_k = torch.cat([k_weight, -j_weight, i_weight, r_weight], dim=1)
cat_kernels_4_quaternion = torch.cat([cat_kernels_4_r, cat_kernels_4_i, cat_kernels_4_j, cat_kernels_4_k], dim=0)
if input.dim() == 3:
convfunc = F.conv_transpose1d
elif input.dim() == 4:
convfunc = F.conv_transpose2d
elif input.dim() == 5:
convfunc = F.conv_transpose3d
else:
raise Exception("The convolutional input is either 3, 4 or 5 dimensions."
" input.dim = " + str(input.dim()))
return convfunc(input, cat_kernels_4_quaternion, bias, stride, padding, output_padding, groups, dilatation)
示例3: _compute_flow_3d
# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import conv_transpose3d [as 别名]
def _compute_flow_3d(self):
# compute dense displacement
displacement = F.conv_transpose3d(self.trans_parameters, self._kernel,
padding=self._padding, stride=self._stride, groups=3)
# crop displacement
return th.squeeze(displacement[:, :, self._stride[0] + self._crop_start[0]:-self._stride[0] - self._crop_end[0],
self._stride[1] + self._crop_start[1]:-self._stride[1] - self._crop_end[1],
self._stride[2] + self._crop_start[2]:-self._stride[2] - self._crop_end[2]
].transpose_(1,4).transpose_(1,3).transpose_(1,2))
示例4: compute_displacement
# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import conv_transpose3d [as 别名]
def compute_displacement(self, params):
# compute dense displacement
displacement = F.conv_transpose3d(params, self.kernel,
padding=self.padding, stride=self.stride, groups=3)
# crop displacement
displacement = displacement[:, :,
self.control_point_spacing[0] + self.crop_start[0]:-self.control_point_spacing[0] -
self.crop_end[0],
self.control_point_spacing[1] + self.crop_start[1]:-self.control_point_spacing[1] -
self.crop_end[1],
self.control_point_spacing[2] + self.crop_start[2]:-self.control_point_spacing[2] -
self.crop_end[2]]
return displacement.permute(0, 2, 3, 4, 1)
示例5: test_conv_transpose3d
# 需要导入模块: from torch.nn import functional [as 别名]
# 或者: from torch.nn.functional import conv_transpose3d [as 别名]
def test_conv_transpose3d(self):
# Data and weight tensors
conv_transpose3d_tensor = torch.randn(20, 16, 50, 10, 20, device='cuda', dtype=self.dtype)
conv_transpose3d_filter = torch.randn(16, 33, 3, 3, 3, device='cuda', dtype=self.dtype)
conv_transpose3d_bias = torch.randn(33, device='cuda', dtype=self.dtype)
# Conv transpose runs
conv_transpose3d_out = F.conv_transpose3d(conv_transpose3d_tensor, conv_transpose3d_filter)
conv_transpose3d_out_biased = F.conv_transpose3d(conv_transpose3d_tensor, conv_transpose3d_filter, bias=conv_transpose3d_bias)
conv_transpose3d_out_strided = F.conv_transpose3d(conv_transpose3d_tensor, conv_transpose3d_filter, stride=2)
conv_transpose3d_out_padded = F.conv_transpose3d(conv_transpose3d_tensor, conv_transpose3d_filter, padding=3)
conv_transpose3d_out2_padded = F.conv_transpose3d(conv_transpose3d_tensor, conv_transpose3d_filter, output_padding=2, dilation=3)
conv_transpose3d_out_grouped = F.conv_transpose3d(conv_transpose3d_tensor, conv_transpose3d_filter, groups=2)
conv_transpose3d_out_dilated = F.conv_transpose3d(conv_transpose3d_tensor, conv_transpose3d_filter, dilation=2)