MCPcopy Create free account
hub / github.com/TrustAGI-Lab/MTGODE / forward

Method forward

model.py:155–191  ·  view source on GitHub ↗
(self, input, idx=None)

Source from the content-addressed store, hash-verified

153 init.zeros_(self.affine_bias)
154
155 def forward(self, input, idx=None):
156 seq_len = input.size(3)
157 assert seq_len == self.seq_length, 'input sequence length not equal to preset sequence length'
158
159 if self.seq_length < self.receptive_field:
160 input = nn.functional.pad(input, (self.receptive_field-self.seq_length, 0))
161
162 if self.buildA_true:
163 if idx is None:
164 adp = self.gc(self.idx)
165 else:
166 adp = self.gc(idx)
167 else:
168 adp = self.predefined_A
169
170 x = self.start_conv(input)
171
172 if self.adjoint:
173 self.ODE.odefunc.stnet.setIntermediate(dilation=1)
174 self.ODE.odefunc.stnet.setGraph(adp)
175 x = self.ODE(x, self.integration_time)
176 self.ODE.odefunc.stnet.setIntermediate(dilation=1)
177
178 x = x[..., -1:]
179 x = F.layer_norm(x, tuple(x.shape[1:]), weight=None, bias=None, eps=1e-5)
180
181 if self.ln_affine:
182 if idx is None:
183 x = torch.add(torch.mul(x, self.affine_weight[:, self.idx].unsqueeze(-1)), self.affine_bias[:, self.idx].unsqueeze(-1)) # C*H
184 else:
185 x = torch.add(torch.mul(x, self.affine_weight[:, idx].unsqueeze(-1)), self.affine_bias[:, idx].unsqueeze(-1)) # C*H
186
187 x = F.relu(self.end_conv_0(x))
188 x = F.relu(self.end_conv_1(x))
189 x = self.end_conv_2(x)
190
191 return x

Callers

nothing calls this directly

Calls 2

setIntermediateMethod · 0.80
setGraphMethod · 0.80

Tested by

no test coverage detected