Loss Functions Module
lossfx wraps PyTorch’s loss functions, optimisers, and learning-rate
schedulers into a single C++ class, and provides weight-initialisation
utilities for torch::nn::Sequential networks. It is used internally by
model_template and exposed to Python via OptimizerConfig in
AnalysisG.core.lossfx.
Class: lossfx
Header: <templates/lossfx.h>
Inheritance: tools, notification
Supported Loss Functions
The following PyTorch loss functions are selectable by name (case-insensitive):
Name string |
PyTorch class |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Supported Optimisers
Name string ( |
PyTorch class |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Supported Learning-Rate Schedulers
Name string ( |
PyTorch class |
|---|---|
|
|
|
|
Public Fields
Field |
Type |
Description |
|---|---|---|
|
|
Name of the output feature this loss function is attached to. |
|
|
Loss-option struct (reduction type, smoothing, margin, …). |
Public Methods
Signature |
Description |
|---|---|
|
Default constructor. |
|
Constructs with feature name var and loss-function name enx. |
|
Computes the loss using the configured loss function. |
|
Computes the loss using an explicit |
|
Builds the loss function from |
|
Builds the loss function for the given enum value. |
|
Constructs and returns the PyTorch optimiser. |
|
Wraps the given optimiser with a learning-rate scheduler. |
|
Applies the weight-initialisation strategy method to data. |
|
Parses a composite option string like |
|
Moves the loss function to the specified device. |
|
Calls the learning-rate scheduler step (if a scheduler is configured). |