MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / Conv1dWN_v2

Class Conv1dWN_v2

modules/networks.py:70–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68
69
70class Conv1dWN_v2(torch.nn.Conv1d):
71 def __init__(
72 self,
73 in_channels,
74 out_channels,
75 kernel_size,
76 stride=1,
77 padding=0,
78 padding_mode="zeros",
79 dilation=1,
80 groups=1,
81 ):
82 super(Conv1dWN_v2, self).__init__(
83 in_channels,
84 out_channels,
85 kernel_size,
86 stride,
87 padding,
88 dilation,
89 groups,
90 True,
91 )
92 self.g = torch.nn.Parameter(torch.ones(out_channels))
93
94 self.padding_amount=padding
95 self.padding_mode=padding_mode
96
97 def forward(self, x):
98 w= torch._weight_norm(self.weight, self.g, 0)
99
100
101
102 if self.padding_mode != 'zeros':
103 x= F.pad(x, (self.padding_amount,self.padding_amount), mode=self.padding_mode)
104
105 x= F.conv1d(
106 x,
107 w,
108 bias=self.bias,
109 stride=self.stride,
110 padding=0,
111 dilation=self.dilation,
112 groups=self.groups,
113 )
114 # print("x after conv", x.shape)
115 return x
116 else:
117
118 return F.conv1d(
119 x,
120 w,
121 bias=self.bias,
122 stride=self.stride,
123 padding=self.padding,
124 dilation=self.dilation,
125 groups=self.groups,
126 )
127

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected