fork download
  1. class ConvTranspose2d(nn.ConvTranspose2d):
  2.  
  3. def __init__(self, in_channels, out_channels, kernel_size, stride=1,
  4. padding=0, output_padding=1, groups=1, bias=True, dilation=1):
  5. super(ConvTranspose2d, self).__init__(in_channels, out_channels, kernel_size, stride,
  6. padding, output_padding, groups, bias, dilation)
  7.  
  8. def forward(self, x):
  9. weight = self.weight
  10. weight_mean = weight.mean(dim=1, keepdim=True).mean(dim=2,
  11. keepdim=True).mean(dim=3, keepdim=True)
  12. weight = weight - weight_mean
  13. std = weight.view(weight.size(0), -1).std(dim=1).view(-1, 1, 1, 1) + 1e-5
  14. weight = weight / std.expand_as(weight)
  15. return F.conv_transpose2d(x, weight, self.bias, self.stride,
  16. self.padding, self.output_padding, self.groups, self.dilation)
Runtime error #stdin #stdout #stderr 0.12s 23556KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
NameError: name 'nn' is not defined