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

Method forward

sat/vae_modules/regularizers.py:98–108  ·  view source on GitHub ↗
(self, z: torch.Tensor)

Source from the content-addressed store, hash-verified

96 yield from ()
97
98 def forward(self, z: torch.Tensor) -> Tuple[torch.Tensor, dict]:
99 log = dict()
100 posterior = DiagonalGaussianDistribution(z)
101 if self.sample:
102 z = posterior.sample()
103 else:
104 z = posterior.mode()
105 kl_loss = posterior.kl()
106 kl_loss = torch.sum(kl_loss) / kl_loss.shape[0]
107 log["kl_loss"] = kl_loss
108 return z, log

Callers

nothing calls this directly

Calls 4

sampleMethod · 0.95
modeMethod · 0.95
klMethod · 0.95

Tested by

no test coverage detected