68 const std::vector<Tensor>& background,
const PrototypeOptions& options = {});
One JSON value: null, a boolean, a number, a string, an array or an object.
Definition json.hpp:22
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
A small strict JSON value, parser and deterministic writer (RFC 8259).
Definition acquisition_functions.hpp:16
std::function< std::vector< float >(const Tensor &input)> EmbedFn
Maps an input to the vector distances are measured in.
Definition prototypes.hpp:27
PrototypeResult FindPrototypes(const std::function< Tensor(const Tensor &)> &predict, const Tensor &input, const std::vector< Tensor > &background, const PrototypeOptions &options={})
The background examples nearest input that the model classes the same way, and those it classes diffe...
ProtoDashResult ProtoDash(const std::vector< Tensor > &source, const std::vector< Tensor > &target, const ProtoDashOptions &options={})
ProtoDash: chooses up to options.count points of source, with weights, whose weighted kernel mean bes...
JsonValue ToJson(const AttackResult &result, const AttackOptions &options)
The result as a pulsatrix.attack.v1 document, without the adversarial inputs.
One background example.
Definition prototypes.hpp:41
int64_t index
Its index in the background.
Definition prototypes.hpp:43
int64_t predicted_class
The model's class for it.
Definition prototypes.hpp:46
double distance
Definition prototypes.hpp:44
ProtoDash()'s settings.
Definition prototypes.hpp:71
EmbedFn embed
Distances in this representation instead of the input space.
Definition prototypes.hpp:78
int64_t count
How many prototypes to choose, at most.
Definition prototypes.hpp:73
double sigma
The Gaussian kernel's width, exp(-|a - b|^2 / (2 sigma^2)); 0 for the median distance between the sou...
Definition prototypes.hpp:76
ProtoDash()'s result.
Definition prototypes.hpp:82
std::vector< double > weights
Their non-negative weights, which sum to 1: how much of the target each stands for.
Definition prototypes.hpp:86
std::vector< double > objective
The objective w'mu - w'Kw/2 (unnormalized weights) after each choice; it never falls.
Definition prototypes.hpp:88
double sigma
Definition prototypes.hpp:89
std::vector< int64_t > indices
The chosen source points, in the order chosen.
Definition prototypes.hpp:84
FindPrototypes()' settings.
Definition prototypes.hpp:30
int64_t k
How many prototypes, and how many contrasts.
Definition prototypes.hpp:32
EmbedFn embed
Measure distances in this representation instead of the input space.
Definition prototypes.hpp:37
std::vector< float > scale
Per-feature distance scale in the input space (a change of scale[j] counts 1); empty for 1....
Definition prototypes.hpp:35
FindPrototypes()' result.
Definition prototypes.hpp:50
std::vector< Example > prototypes
The nearest examples the model gives the same class, nearest first.
Definition prototypes.hpp:54
int64_t predicted_class
The model's class for the input.
Definition prototypes.hpp:52
std::vector< Example > contrasts
The nearest examples the model gives another class, nearest first.
Definition prototypes.hpp:56
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).