loss¶
Loss Function Handling
MuyGPyS includes predefined loss functions and convenience functions for indicating them to optimization.
- MuyGPyS.optimize.loss.cross_entropy_fn(predictions, targets)[source]¶
Cross entropy function.
Computes the cross entropy loss the predicted versus known response. Transforms
predictions
to be row-stochastic, and ensures thattargets
contains no negative elements.@NOTE[bwp] I don’t remember why we hard-coded eps=1e-6. Might need to revisit.
- Parameters
predictions (
ndarray
) – The predicted response of shape(batch_count, response_count)
.targets (
ndarray
) – The expected response of shape(batch_count, response_count)
.
- Return type
float
- Returns
The cross-entropy loss of the prediction.
- MuyGPyS.optimize.loss.get_loss_func(loss_method)[source]¶
Select a loss function based upon string key.
Currently supports strings
"log"
or"cross-entropy"
forMuyGPyS.optimize.objective.cross_entropy_fn()
and"mse"
forMuyGPyS.optimize.objective.mse_fn()
.- Parameters
predictions – The predicted response of shape
(batch_count, response_count)
.targets – The expected response of shape
(batch_count, response_count)
.
- Return type
Callable
- Returns
The loss function Callable.
- Raises
NotImplementedError – Unrecognized strings will result in an error.
- MuyGPyS.optimize.loss.lool_fn(predictions, targets, variances, sigma_sq)[source]¶
Leave-one-out likelihood function.
Computes leave-one-out likelihood (LOOL) loss of the predicted versus known response. Treats multivariate outputs as interchangeable in terms of loss penalty.
- Parameters
predictions (
ndarray
) – The predicted response of shape(batch_count, response_count)
.targets (
ndarray
) – The expected response of shape(batch_count, response_count)
.variances (
ndarray
) – The unscaled variance of the predicted responses of shape(batch_count, response_count)
.sigma_sq (
ndarray
) – The sigma_sq variance scaling parameter of shape(response_count,)
.
- Return type
float
- Returns
The LOOL loss of the prediction.
- MuyGPyS.optimize.loss.mse_fn(predictions, targets)[source]¶
Mean squared error function.
Computes mean squared error loss of the predicted versus known response. Treats multivariate outputs as interchangeable in terms of loss penalty.
- Parameters
predictions (
ndarray
) – The predicted response of shape(batch_count, response_count)
.targets (
ndarray
) – The expected response of shape(batch_count, response_count)
.
- Return type
float
- Returns
The mse loss of the prediction.