MCPcopy Create free account
hub / github.com/dangf15/THLNet / forward

Method forward

complexnn.py:187–214  ·  view source on GitHub ↗
(self,inputs)

Source from the content-addressed store, hash-verified

185 nn.init.constant_(self.imag_conv.bias,0.)
186
187 def forward(self,inputs):
188
189 if isinstance(inputs, torch.Tensor):
190 real,imag = torch.chunk(inputs, 2, self.complex_axis)
191 elif isinstance(inputs, tuple) or isinstance(inputs, list):
192 real = inputs[0]
193 imag = inputs[1]
194 if self.complex_axis == 0:
195 real = self.real_conv(inputs)
196 imag = self.imag_conv(inputs)
197 real2real,imag2real = torch.chunk(real,2, self.complex_axis)
198 real2imag,imag2imag = torch.chunk(imag,2, self.complex_axis)
199
200 else:
201 if isinstance(inputs, torch.Tensor):
202 real,imag = torch.chunk(inputs, 2, self.complex_axis)
203
204 real2real = self.real_conv(real,)
205 imag2imag = self.imag_conv(imag,)
206
207 real2imag = self.imag_conv(real)
208 imag2real = self.real_conv(imag)
209
210 real = real2real - imag2imag
211 imag = real2imag + imag2real
212 out = torch.cat([real, imag], self.complex_axis)
213
214 return out
215
216# Source: https://github.com/ChihebTrabelsi/deep_complex_networks/tree/pytorch
217# from https://github.com/IMLHF/SE_DCUNet/blob/f28bf1661121c8901ad38149ea827693f1830715/models/layers/complexnn.py#L55

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected