def _get_latent_loss(self, mu_lat, logs_lat, mu_next_obs, sigma_next_obs,
                         targ_next_obs):
        log_prob = log_gaussian_prob(mu_next_obs, sigma_next_obs,
                                     targ_next_obs)  # P(s' | s, a, z)
        kl = kl_regularization(mu_lat, logs_lat)  # KL(q_phi || N(0,1))

        return -log_prob + self._beta_kl * kl, log_prob, kl
Exemple #2
0
def loss_fn(inputs: d, outputs: d, model_outputs: d) -> torch.Tensor:
    return -log_gaussian_prob(model_outputs.next_obs,
                              model_outputs.next_obs_sigma,
                              outputs.next_obs.unsqueeze(1))