Python torch.nn 模块,ConvTranspose3d() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用torch.nn.ConvTranspose3d()

项目:SGAN    作者:YuhangSong    | 项目源码 | 文件源码
def weights_init(m):
    classname = m.__class__.__name__
    if classname.find('Linear') != -1:
        torch.nn.init.xavier_uniform(
            m.weight.data,
            gain=1
        )
        m.bias.data.fill_(0.1)
    # elif classname.find('Conv3d') != -1:
    #     torch.nn.init.xavier_uniform(
    #         m.weight.data,
    #         gain=1
    #     )
    # elif classname.find('ConvTranspose3d') != -1:
    #     torch.nn.init.xavier_uniform(
    #         m.weight.data,
    #         gain=1
    #     )
项目:vnet.pytorch    作者:mattmacy    | 项目源码 | 文件源码
def __init__(self, inChans, outChans, nConvs, elu, dropout=False):
        super(UpTransition, self).__init__()
        self.up_conv = nn.ConvTranspose3d(inChans, outChans // 2, kernel_size=2, stride=2)
        self.bn1 = ContBatchNorm3d(outChans // 2)
        self.do1 = passthrough
        self.do2 = nn.Dropout3d()
        self.relu1 = ELUCons(elu, outChans // 2)
        self.relu2 = ELUCons(elu, outChans)
        if dropout:
            self.do1 = nn.Dropout3d()
        self.ops = _make_nConv(outChans, nConvs, elu)
项目:covfefe    作者:deepnn    | 项目源码 | 文件源码
def conv_transpose(in_ch, out_ch, kernel_size,
                      stride=1, padding=0, out_padding=0, 
                      dilation=1, groups=1, bias=True, dim=2):

    #TODO: in the future some preprocessing goes here
    in_dim = dim
    if in_dim == 1:
        return nn.ConvTranspose1d(in_ch, out_ch, kernel_size,
                        stride=stride,
                        padding=padding,
                        output_padding=out_padding,
                        dilation=dilation,
                        groups=groups,
                        bias=bias)

    elif in_dim == 2:
        return nn.ConvTranspose2d(in_ch, out_ch, kernel_size,
                        stride=stride,
                        padding=padding,
                        output_padding=out_padding,
                        dilation=dilation,
                        groups=groups,
                        bias=bias)

    elif in_dim == 3:
        return nn.ConvTranspose3d(in_ch, out_ch, kernel_size,
                        stride=stride,
                        padding=padding,
                        output_padding=out_padding,
                        dilation=dilation,
                        groups=groups,
                        bias=bias)

# pooling
项目:pytorch    作者:ezyang    | 项目源码 | 文件源码
def test_conv_modules_raise_error_on_incorrect_input_size(self):
        modules = [nn.Conv1d(3, 8, 3), nn.ConvTranspose1d(3, 8, 3),
                   nn.Conv2d(3, 8, 3), nn.ConvTranspose2d(3, 8, 3),
                   nn.Conv3d(3, 8, 3), nn.ConvTranspose3d(3, 8, 3)]

        invalid_input_dims = [(2, 4), (2, 4),
                              (3, 5), (3, 5),
                              (4, 6), (4, 6)]

        for invalid_dims, module in zip(invalid_input_dims, modules):
            for dims in invalid_dims:
                input = Variable(torch.Tensor(torch.Size((3, ) * dims)))
                self.assertRaises(ValueError, lambda: module(input))
项目:pytorch-planet-amazon    作者:rwightman    | 项目源码 | 文件源码
def is_sparseable(m):
    return True if hasattr(m, 'weight') and isinstance(m, (
            nn.Conv1d, nn.Conv2d, nn.Conv3d,
            nn.ConvTranspose1d, nn.ConvTranspose2d, nn.ConvTranspose3d,
            nn.Linear)) else False
项目:pytorch    作者:pytorch    | 项目源码 | 文件源码
def test_conv_modules_raise_error_on_incorrect_input_size(self):
        modules = [nn.Conv1d(3, 8, 3), nn.ConvTranspose1d(3, 8, 3),
                   nn.Conv2d(3, 8, 3), nn.ConvTranspose2d(3, 8, 3),
                   nn.Conv3d(3, 8, 3), nn.ConvTranspose3d(3, 8, 3)]

        invalid_input_dims = [(2, 4), (2, 4),
                              (3, 5), (3, 5),
                              (4, 6), (4, 6)]

        for invalid_dims, module in zip(invalid_input_dims, modules):
            for dims in invalid_dims:
                input = Variable(torch.Tensor(torch.Size((3, ) * dims)))
                self.assertRaises(ValueError, lambda: module(input))