56 const Tensor& input, int64_t samples);
117 const std::vector<std::vector<double>>& variances = {});
158 double min_variance_;
160 std::vector<float> last_target_;
161 bool has_forwarded_ =
false;
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:248
The Gaussian negative log likelihood, for regressors that predict their own noise (Nix and Weigend,...
Definition uncertainty.hpp:130
double variance(double s) const
The variance a prediction's s gives: softplus(s) + min_variance.
float forward(const Tensor &prediction, const Tensor &target)
GaussianNLLLoss(DeviceBackend *backend, double min_variance=1e-6)
Tensor backward() const
The gradient with respect to the prediction, (N, 2).
One JSON value: null, a boolean, a number, a string, an array or an object.
Definition json.hpp:22
Base class for every layer type (LinearModule, Conv2DModule, activations, ...).
Definition module.hpp:78
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Abstract interface isolating vendor-specific memory/compute operations from Tensor/ComputationGraph.
A small strict JSON value, parser and deterministic writer (RFC 8259).
Abstract base every layer subclasses – NVI forward(), pure-virtual LRP contract.
Definition acquisition_functions.hpp:16
std::vector< Tensor > McDropoutSamples(Module &model, const std::function< Tensor(const Tensor &)> &predict, const Tensor &input, int64_t samples)
Monte Carlo dropout: runs predict on input samples times with every dropout layer under model in trai...
JsonValue ToJson(const AttackResult &result, const AttackOptions &options)
The result as a pulsatrix.attack.v1 document, without the adversarial inputs.
GaussianMixturePrediction CombineGaussians(const std::vector< std::vector< double > > &means, const std::vector< std::vector< double > > &variances={})
Mixes M Gaussian predictions per input into one, as Lakshminarayanan et al. do: the mixture's mean is...
UncertaintyDecomposition DecomposeUncertainty(const std::vector< Tensor > &samples)
Splits the uncertainty of a set of probability samples into its aleatoric and epistemic parts,...
std::vector< Tensor > EnsembleSamples(const std::vector< std::function< Tensor(const Tensor &)> > &members, const Tensor &input)
A deep ensemble's samples: each member's output for input.
CombineGaussians()' result: one value per input.
Definition uncertainty.hpp:95
std::vector< double > epistemic
The variance of the members' means: how much they disagree.
Definition uncertainty.hpp:103
std::vector< double > variance
The mixture's variance: aleatoric + epistemic.
Definition uncertainty.hpp:99
std::vector< double > mean
The mixture's mean, the members' mean.
Definition uncertainty.hpp:97
std::vector< double > aleatoric
The members' mean variance: the noise each predicts.
Definition uncertainty.hpp:101
DecomposeUncertainty()'s result: one value per input, entropies in nats.
Definition uncertainty.hpp:68
std::vector< double > total
H[E p], the entropy of the mean.
Definition uncertainty.hpp:74
std::vector< int64_t > predicted
The most probable class of the mean, the lower index on a tie.
Definition uncertainty.hpp:72
std::vector< double > aleatoric
E H[p], the samples' mean entropy.
Definition uncertainty.hpp:76
std::vector< double > agreement
The fraction of samples whose most probable class is the mean's.
Definition uncertainty.hpp:80
int64_t samples
Definition uncertainty.hpp:81
Tensor mean
The mean of the samples' probabilities, (N, K): the prediction to use.
Definition uncertainty.hpp:70
std::vector< double > epistemic
total - aleatoric, the mutual information (never negative).
Definition uncertainty.hpp:78
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).