pytorch报错 ConvTranspose1d object has no attribute padding_mode

2022年12月25日09:26:15

‘ConvTranspose1d’ object has no attribute 'padding_mode’错误:https://github.com/NVIDIA/tacotron2/issues/182

解决方法:
Using torch 1.1.0.dev20190512 and waveglow_256channels.pt I was still getting this error. Following @apsears I managed to get it working. Here are the locations and changes required

即将一下 conv.py文件中的190行修改:
envs/nlp/lib/python3.6/site-packages/torch/nn/modules/conv.py line 190

 @weak_script_method
 def forward(self, input):
        if False: # self.padding_mode == 'circular'
            expanded_padding = ((self.padding[0] + 1) // 2, self.padding[0] // 2)
            return F.conv1d(F.pad(input, expanded_padding, mode='circular'),
                            self.weight, self.bias, self.stride,
                            _single(0), self.dilation, self.groups)
        return F.conv1d(input, self.weight, self.bias, self.stride,
                        self.padding, self.dilation, self.groups)

及641行

    @weak_script_method
    def forward(self, input, output_size=None):
        # type: (Tensor, Optional[List[int]]) -> Tensor
        #if self.padding_mode != 'zeros':
        #    raise ValueError('Only `zeros` padding mode is supported for ConvTranspose1d')

        output_padding = self._output_padding(input, output_size, self.stride, self.padding, self.kernel_size)
        return F.conv_transpose1d(
            input, self.weight, self.bias, self.stride, self.padding,
            output_padding, self.groups, self.dilation)

  • 作者:Zero_to_zero1234
  • 原文链接:https://blog.csdn.net/suiyueruge1314/article/details/106540382
    更新时间:2022年12月25日09:26:15 ,共 1139 字。