MCPcopy Create free account
hub / github.com/CompVis/diff2flow / forward

Method forward

diff2flow/kl_autoencoder.py:409–442  ·  view source on GitHub ↗
(self, z)

Source from the content-addressed store, hash-verified

407 padding=1)
408
409 def forward(self, z):
410 #assert z.shape[1:] == self.z_shape[1:]
411 self.last_z_shape = z.shape
412
413 # timestep embedding
414 temb = None
415
416 # z to block_in
417 h = self.conv_in(z)
418
419 # middle
420 h = self.mid.block_1(h, temb)
421 h = self.mid.attn_1(h)
422 h = self.mid.block_2(h, temb)
423
424 # upsampling
425 for i_level in reversed(range(self.num_resolutions)):
426 for i_block in range(self.num_res_blocks+1):
427 h = self.up[i_level].block[i_block](h, temb)
428 if len(self.up[i_level].attn) > 0:
429 h = self.up[i_level].attn[i_block](h)
430 if i_level != 0:
431 h = self.up[i_level].upsample(h)
432
433 # end
434 if self.give_pre_end:
435 return h
436
437 h = self.norm_out(h)
438 h = nonlinearity(h)
439 h = self.conv_out(h)
440 if self.tanh_out:
441 h = torch.tanh(h)
442 return h
443
444
445""" KL-regularized Autoencoder """

Callers

nothing calls this directly

Calls 1

nonlinearityFunction · 0.85

Tested by

no test coverage detected