Loss Functions#
- NeuralFieldManifold.utils.loss_p(p_logits, p_true)[source]#
Cross-entropy loss for AR-order classification.
- Parameters:
p_logits (torch.Tensor) – Raw logits of shape
(N, n_classes).p_true (torch.Tensor) – Ground-truth class indices of shape
(N,).
- Returns:
Scalar cross-entropy loss.
- Return type:
- NeuralFieldManifold.utils.loss_ar(x, x_hat, p_max)[source]#
Mean squared error between the true and reconstructed signal.
Only the portion after the first p_max time steps is considered to avoid the zero-padded region where lagged values are unavailable.
- Parameters:
x (torch.Tensor) – True input signal of shape
(N, T).x_hat (torch.Tensor) – Reconstructed signal of shape
(N, T).p_max (int) – Maximum AR order; the first p_max steps are excluded.
- Returns:
Scalar MSE loss.
- Return type:
- NeuralFieldManifold.utils.loss_energy(x_hat, P0=0.5, W=40)[source]#
Sliding-window power constraint loss.
Penalises deviations of the local mean-squared power from the target level P0 by computing the MSE between windowed power and P0 across all positions.
- Parameters:
x_hat (torch.Tensor) – Reconstructed signal of shape
(N, T).P0 (float, optional) – Target power level. Default is 0.5.
W (int, optional) – Sliding-window size. Default is 40.
- Returns:
Scalar energy loss.
- Return type:
- NeuralFieldManifold.utils.loss_smooth(coeffs)[source]#
Temporal smoothness penalty on AR coefficients.
Computes the mean squared first-order difference of the coefficient trajectories along the time axis.
- Parameters:
coeffs (torch.Tensor) – Predicted AR coefficients of shape
(N, T, max_ar_order).- Returns:
Scalar smoothness loss.
- Return type: