libdl  0.0.1
Simple yet powerful deep learning
Loading...
Searching...
No Matches
evaluators.hpp
Go to the documentation of this file.
1
6#ifndef DL_LEARNING_EVALUATORS_HPP
7#define DL_LEARNING_EVALUATORS_HPP
8
9#include "../device.hpp"
10#include "../tensor/tensorptr.hpp"
11
12namespace dl {
13
14 class MeanError {
15 private:
16 dl::TensorPtr sum;
17 size_t num;
18
19 public:
20 MeanError() noexcept : sum(dl::constant(0)), num(0) {}
21
22 MeanError& operator+=(dl::TensorPtr loss) noexcept {
23 sum = sum + dl::sum(loss);
24 num += dl::numEntries(loss);
25 return *this;
26 }
27
28 dl::TensorPtr aggregated() const { return sum / (float)num; }
29 };
30
31} // namespace dl
32
33#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 sum(TensorPtr x) noexcept
Sum.
size_t numEntries(const TensorPtr &tensor) noexcept
Returns the number of entries in the tensor.