Loading...
Searching...
No Matches
loss.h
Go to the documentation of this file.
95 void set_neural_network(NeuralNetwork* new_neural_network) { neural_network = new_neural_network; }
99 void set_regularization(const string& new_regularization_method) { regularization_method = string_to_regularization(new_regularization_method); }
100 void set_regularization(Regularization new_regularization) { regularization_method = new_regularization; }
101 void set_regularization_weight(const float new_regularization_weight) { regularization_weight = new_regularization_weight; }
Abstract base class for OpenNN datasets, owning samples, variables, and metadata.
Definition dataset.h:61
Definition json.h:72
Definition json.h:85
static Regularization string_to_regularization(const string &name)
Parses a regularization name (accepts both "NoRegularization" and "None") back to the enum.
Definition loss.h:59
float calculate_regularization(const VectorR &) const
Returns the regularization penalty (L1, L2, or ElasticNet) for the given parameter vector.
void set_regularization(const string &new_regularization_method)
Definition loss.h:99
void from_JSON(const JsonDocument &)
Restores loss configuration (error type, regularization, weights) from a JSON document.
void regularization_from_JSON(const JsonDocument &)
Restores the regularization sub-configuration from JSON.
static float calculate_h(const float)
Returns the finite-difference step size h tuned for the given parameter value.
static const string & regularization_to_string(Regularization regularization)
Returns the canonical string name for a Regularization value.
Definition loss.h:53
void print() const
Prints a human-readable description of the loss (no-op default).
Definition loss.h:172
void set(NeuralNetwork *=nullptr, Dataset *=nullptr)
Resets the bound neural network and dataset pointers.
void set_normalization_coefficient()
Recomputes the normalization coefficient (used by NormalizedSquaredError) from the dataset.
void regularization_to_JSON(JsonWriter &) const
Serializes the regularization sub-configuration to JSON.
static const EnumMap< Regularization > & regularization_map()
Returns the static string<->enum map used to (de)serialize regularization types.
Definition loss.h:40
void back_propagate(const Batch &, ForwardPropagation &, BackPropagation &) const
Performs the full backward pass: output deltas, layer gradients, and regularization gradient.
void set_error(const string &)
Selects the error function variant from its string name.
void set_neural_network(NeuralNetwork *new_neural_network)
Definition loss.h:95
EvaluationResult calculate_error(const Batch &, const ForwardPropagation &) const
Computes the loss for one batch using the cached forward-pass outputs.
void to_JSON(JsonWriter &) const
Serializes the loss configuration (error type, regularization, weights) to JSON.
Loss(NeuralNetwork *=nullptr, Dataset *=nullptr)
Constructs a Loss bound to an optional neural network and dataset.
Regularization
Parameter regularization method applied on top of the base loss.
Definition loss.h:37
virtual ~Loss()=default
void set_regularization_weight(const float new_regularization_weight)
Definition loss.h:101
Error
Error function selector used to dispatch the loss kernel.
Definition loss.h:29
void set_regularization(Regularization new_regularization)
Definition loss.h:100
const NeuralNetwork * get_neural_network() const
Definition loss.h:72
Container of layers forming a feed-forward neural network, with parameter storage and I/O.
Definition neural_network.h:20
Definition adaptive_moment_estimation.h:14
Workspace holding parameter gradients and per-layer deltas during a backward pass.
Definition back_propagation.h:21
Minibatch container holding pinned host/device buffers and views into a Dataset.
Definition batch.h:19
Owning raw byte buffer that lives on CPU or CUDA memory, with aligned (re)allocation.
Definition tensor_utilities.h:166
Definition enum_map.h:18
Workspace holding the activations of every layer during a forward pass.
Definition forward_propagation.h:20
Result of calculate_error; accuracy and active_tokens_count are populated only by classification loss...
Definition loss.h:108