rpn_loss

probly.losses.torch.rpn_loss(model: Module, x_id: Tensor, y_id: Tensor, x_ood: Tensor, lam_der: float = 0.01, lam_rpn: float = 50.0) Tensor[source]

Paired ID/OOD Regression Prior Network loss based on [MCPG20].

Computes a Regression Prior Network (RPN) training objective using paired in-distribution (ID) and out-of-distribution (OOD) mini-batches. The loss combines a supervised Deep Evidential Regression (DER) term on ID data with a KL regularization term that pushes OOD predictions back toward the Normal-Gamma prior.

Parameters:
  • model – Regression model returning a dict with the keys “gamma”, “nu”, “alpha” and “beta”, as produced by probly.method.evidential.evidential_regression().

  • x_id – In-distribution inputs, shape (B_id, …).

  • y_id – In-distribution regression targets, shape (B_id,) or compatible.

  • x_ood – Out-of-distribution inputs, shape (B_ood, …).

  • lam_der – Weight of the DER evidence regularization term.

  • lam_rpn – Weight of the RPN prior-matching KL term.

Returns:

Scalar paired ID+OOD Regression Prior Network loss.