libdl  0.0.1
Simple yet powerful deep learning
Loading...
Searching...
No Matches
adapters.hpp File Reference

Contains some general purpose loss adapters. More...

#include <concepts>
Include dependency graph for adapters.hpp:

Go to the source code of this file.

Functions

auto dl::lossAdapter (auto lossObjective)
 A training adapter for applying a single loss objective.
 

Detailed Description

Contains some general purpose loss adapters.

Definition in file adapters.hpp.

Function Documentation

◆ lossAdapter()

auto dl::lossAdapter ( auto  lossObjective)

A training adapter for applying a single loss objective.

Let \(\mathcal M\colon X\to Y\) denote the model to be trained or evaluated, where \(X\) is the space of all inputs and \(Y\) is the space of all outputs. Further, let \(\mathcal L\colon Y\times Y \to \mathbb R\) denote a loss objective. Given the input \(x\in X\) and desired output \(y\in Y\), the loss adapter returns

\[\mathcal{L}(\mathcal{M}(x), y).\]

Or, in short: The loss adapter tells the trainer to optimize the given loss objective.

Parameters
lossObjectivethe loss objective to be optimized for.
Returns
A loss adapter for optimizing the specified loss objective.

Definition at line 25 of file adapters.hpp.

25 {
26 constexpr auto func = [](auto loss, auto& model, auto& x, auto& y) { return loss(model(x), y); };
27 return std::bind_front(func, lossObjective);
28 }