libdl  0.0.1
Simple yet powerful deep learning
Loading...
Searching...
No Matches
loss.hpp
Go to the documentation of this file.
1
6#ifndef DL_LEARNING_LOSS_HPP
7#define DL_LEARNING_LOSS_HPP
8
9#include "../tensor/math.hpp"
10
11namespace dl::loss {
23 TensorPtr mse(TensorPtr x, TensorPtr y) noexcept { return dl::mean(dl::pow(x - y, 2.0f)); }
24
38 return -dl::mean(y * dl::log(x) + (1.0f - y) * dl::log(1.0f - x));
39 }
40} // namespace dl::loss
41
42#endif
The Tensor is a managed pointer to a tensor. It can generally be thought of like an std::unique_ptr<T...
Definition tensorptr.hpp:45
TensorPtr pow(TensorPtr base, float exponent) noexcept
Computes the exponent -th power of each element in base and returns the resulting tensor.
TensorPtr log(TensorPtr x) noexcept
Natural logarithm, .
TensorPtr mean(TensorPtr x) noexcept
Mean.
TensorPtr mse(TensorPtr x, TensorPtr y) noexcept
Mean Square Error.
Definition loss.hpp:23
TensorPtr bce(TensorPtr x, TensorPtr y) noexcept
Binary Cross Entropy Loss.
Definition loss.hpp:37