Loss

NonArchimedeanMachineLearning.MPE_loss_initMethod
MPE_loss_init(model::AbstractModel{S}, data::Vector{Tuple{ValuationPolydisc{S,T,N},U}}, p::Int) where {S,T,N,U}

Initialize a Mean p-Power Error (MPE) loss function with polydisc-valued inputs.

Generalizes MSE by using the $\ell^p$ norm instead of $\ell^2$. Computes: $\mathcal{L}(\theta) = \frac{1}{n} \sum_{i=1}^n |f(x_i; \theta) - y_i|^p$

Arguments

  • model::AbstractModel{S}: The model structure specifying the function and parameter layout
  • data::Vector{Tuple{ValuationPolydisc{S,T,N},U}}: Training data as (input_polydisc, output_value) pairs
  • p::Int: The power for the loss (must be finite; for $p = \infty$ use sup loss - TODO)

Returns

Loss: Loss structure with closures for batch evaluation and gradient computation

Notes

For MSE (Euclidean loss), use $p = 2$. The gradient computation uses the power rule. Uses typed evaluators for improved performance.

source
NonArchimedeanMachineLearning.MPE_loss_initMethod
MPE_loss_init(model::AbstractModel{S}, data::Vector{Tuple{S,U}}, p::Int) where {S,U}

Initialize a Mean p-Power Error (MPE) loss function with field-valued inputs.

Generalizes MSE using the $\ell^p$ norm with field-valued (not polydisc-valued) inputs. Uses model specialization and typed evaluators for computational efficiency.

Computes: $\mathcal{L}(\theta) = \frac{1}{n} \sum_{i=1}^n |f(x_i; \theta) - y_i|^p$

Arguments

  • model::AbstractModel{S}: The model structure specifying the function and parameter layout
  • data::Vector{Tuple{S,U}}: Training data as (field_element_input, output_value) pairs
  • p::Int: The power for the loss (must be finite; for $p = \infty$ use sup loss - TODO)

Returns

Loss: Loss structure with closures for batch evaluation and gradient computation

Implementation Notes

This overload specializes the model at each data point, making it more efficient for field-valued inputs than the polydisc variant. Uses typed evaluators for improved performance.

source
NonArchimedeanMachineLearning.MPE_loss_initMethod
MPE_loss_init(model::AbstractModel{S}, data::Vector{Tuple{Vector{S},U}}, p::Int) where {S, U}

Initialize a Mean p-Power Error (MPE) loss function with vector-valued inputs.

Generalizes MPE for data where inputs are vectors of field elements (representing multivariate data points). Uses model specialization and typed evaluators for efficiency.

Computes: $\mathcal{L}(\theta) = \frac{1}{n} \sum_{i=1}^n |f(\mathbf{x}_i; \theta) - y_i|^p$

Arguments

  • model::AbstractModel{S}: The model structure specifying the function and parameter layout
  • data::Vector{Tuple{Vector{S},U}}: Training data as (vector_of_field_elements, output_value) pairs
  • p::Int: The power for the loss (must be finite; for $p = \infty$ use sup loss - TODO)

Returns

Loss: Loss structure with closures for batch evaluation and gradient computation

Implementation Notes

This overload handles multivariate data where each input is a vector of field elements. The model is specialized at each data point vector and uses typed evaluators for improved performance.

source
NonArchimedeanMachineLearning.MSE_loss_initMethod
MSE_loss_init(model::AbstractModel{S}, data::Vector{Tuple{ValuationPolydisc{S,T,N},U}}) where {S,T,N,U}

Initialize a Mean Squared Error (MSE) loss function with polydisc-valued inputs.

Creates a Loss structure with batch evaluation and gradient functions for MSE loss: $\mathcal{L}(\theta) = \frac{1}{n} \sum_{i=1}^n (f(x_i; \theta) - y_i)^2$

Arguments

  • model::AbstractModel{S}: The model structure specifying the function and parameter layout
  • data::Vector{Tuple{ValuationPolydisc{S,T,N},U}}: Training data as (input_polydisc, output_value) pairs

Returns

Loss: Loss structure with closures for batch evaluation and gradient computation

Notes

Both the evaluation and gradient functions operate on batches of parameters and tangent vectors, allowing efficient parallel computation. Uses typed evaluators for improved performance.

source
NonArchimedeanMachineLearning.MSE_loss_initMethod
MSE_loss_init(model::AbstractModel{S}, data::Vector{Tuple{S,U}}) where {S,U}

Initialize a Mean Squared Error (MSE) loss function with field-valued inputs.

Creates a Loss structure for data where inputs are elements of the base field (not polydiscs). This variant uses model specialization and batch evaluation for computational efficiency.

Computes: $\mathcal{L}(\theta) = \frac{1}{n} \sum_{i=1}^n (f(x_i; \theta) - y_i)^2$

Arguments

  • model::AbstractModel{S}: The model structure specifying the function and parameter layout
  • data::Vector{Tuple{S,U}}: Training data as (field_element_input, output_value) pairs

Returns

Loss: Loss structure with closures for batch evaluation and gradient computation

Implementation Notes

This overload specializes the model at each data point by substituting the field-valued inputs, then uses typed evaluators for both evaluation and gradient computation.

source