Tatooine
huber_loss.h
Go to the documentation of this file.
1#ifndef TATOOINE_HUBER_LOSS_H
2#define TATOOINE_HUBER_LOSS_H
3//==============================================================================
4#include <tatooine/concepts.h>
5#include <tatooine/math.h>
6#include <tatooine/real.h>
7//==============================================================================
8namespace tatooine {
9//==============================================================================
11template <arithmetic Delta = int>
12auto constexpr huber_loss(floating_point auto const a, Delta const delta = 1) {
13 if (gcem::abs(a) <= delta) {
14 return a * a / 2;
15 }
16 return delta * (gcem::abs(a) - delta / 2);
17}
18//==============================================================================
19} // namespace tatooine
20//==============================================================================
21#endif
Definition: concepts.h:30
Definition: algorithm.h:6
auto constexpr huber_loss(floating_point auto const a, Delta const delta=1)
See Wikipedia
Definition: huber_loss.h:12