MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / forward

Method forward

sat/sgm/modules/autoencoding/vqvae/vqvae_blocks.py:227–254  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

225 )
226
227 def forward(self, x):
228 # assert x.shape[2] == x.shape[3] == self.resolution, "{}, {}, {}".format(x.shape[2], x.shape[3], self.resolution)
229
230 # timestep embedding
231 temb = None
232
233 # downsampling
234 hs = [self.conv_in(x)]
235 for i_level in range(self.num_resolutions):
236 for i_block in range(self.num_res_blocks):
237 h = self.down[i_level].block[i_block](hs[-1], temb)
238 if len(self.down[i_level].attn) > 0:
239 h = self.down[i_level].attn[i_block](h)
240 hs.append(h)
241 if i_level != self.num_resolutions - 1:
242 hs.append(self.down[i_level].downsample(hs[-1]))
243
244 # middle
245 h = hs[-1]
246 h = self.mid.block_1(h, temb)
247 h = self.mid.attn_1(h)
248 h = self.mid.block_2(h, temb)
249
250 # end
251 h = self.norm_out(h)
252 h = nonlinearity(h)
253 h = self.conv_out(h)
254 return h
255
256 def forward_with_features_output(self, x):
257 # assert x.shape[2] == x.shape[3] == self.resolution, "{}, {}, {}".format(x.shape[2], x.shape[3], self.resolution)

Callers

nothing calls this directly

Calls 2

appendMethod · 0.80
nonlinearityFunction · 0.70

Tested by

no test coverage detected