DeepConvexNet#
- class pytorch_forecasting.metrics._mqf2_utils.DeepConvexNet(picnn: Module, dim: int, is_energy_score: bool = False, estimate_logdet: bool = False, m1: int = 10, m2: int | None = None, rtol: float = 0.0, atol: float = 0.001)[source]#
Bases:
DeepConvexFlowClass that takes a partially input convex neural network (picnn) as input and equips it with functions of logdet computation (both estimation and exact computation). This class is based on DeepConvexFlow of the CP-Flow repo (CW-Huang/CP-Flow) For details of the logdet estimator, see
Convex potential flows: Universal probability distributions with optimal transport and convex optimization- Parameters:
picnn – A partially input convex neural network (picnn)
dim – Dimension of the input
is_energy_score – Indicates if energy score is used as the objective function If yes, the network is not required to be strictly convex, so we can just use the picnn otherwise, a quadratic term is added to the output of picnn to render it strictly convex
m1 – Dimension of the Krylov subspace of the Lanczos tridiagonalization used in approximating H of logdet(H)
m2 – Iteration number of the conjugate gradient algorithm used to approximate logdet(H)
rtol – relative tolerance of the conjugate gradient algorithm
atol – absolute tolerance of the conjugate gradient algorithm
- Inherited-members:
Methods
forward_transformget_potential- forward_transform(x: Tensor, logdet: Tensor | None = 0, context: Tensor | None = None, extra: Tensor | None = None) tuple[Tensor, Tensor][source]#
MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself.
If you use the spec or spec_set arguments then only magic methods that exist in the spec will be created.
Attributes and the return value of a MagicMock will also be MagicMocks.
- get_potential(x: Tensor, context: Tensor | None = None) Tensor[source]#
MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself.
If you use the spec or spec_set arguments then only magic methods that exist in the spec will be created.
Attributes and the return value of a MagicMock will also be MagicMocks.