ab.losses¶
Network loss functions.

aboleth.losses.
elbo
(Net, Y, N, KL, likelihood, like_weights=None)¶ Build the evidence lower bound loss for a neural net.
Parameters:  Net (ndarray, Tensor) – the neural net featues of shape (n_samples, N, tasks).
 Y (ndarray, Tensor) – the targets of shape (N, tasks).
 N (int, Tensor) – the total size of the dataset (i.e. number of observations).
 likelihood (Tensor) – the likelihood model to use on the output of the last layer of the neural net, see the ab.likelihoods module.
 like_weights (callable, ndarray, Tensor) – weights to apply to each observation in the expected log likelihood.
This should be an array of shape (N, 1) or can be called as
like_weights(Y)
and should return a (N, 1) array.
Returns: nelbo – the loss function of the Bayesian neural net (negative ELBO).
Return type: Tensor

aboleth.losses.
max_posterior
(Net, Y, regulariser, likelihood, like_weights=None, first_axis_is_obs=True)¶ Build maximum aposteriori (MAP) loss for a neural net.
Parameters:  Net (ndarray, Tensor) – the neural net featues of shape (N, tasks) or (n_samples, N, tasks).
 Y (ndarray, Tensor) – the targets of shape (N, tasks).
 likelihood (Tensor) – the likelihood model to use on the output of the last layer of the neural net, see the ab.likelihoods module.
 like_weights (callable, ndarray, Tensor) – weights to apply to each observation in the expected log likelihood.
This should be an array of shape (N, 1) or can be called as
like_weights(Y)
and should return a (N, 1) array.  first_axis_is_obs (bool) – indicates if the first axis indexes the observations/data or not. This
will be True if
Net
is of shape (N, tasks) or False ifNet
is of shape (n_samples, N, tasks).
Returns: map – the loss function of the MAP neural net.
Return type: Tensor