philsupertramp/game-math
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Matrix.h"
4#include "../matrix_utils.h"
5
6double relu(const double& in) { return std::max(0.0, in); }
7double sigmoid(const double& in) { return 1.0 / (1.0 + exp(-in)); }
8
10 // real sigmoid in lambda
11 return in.Apply([](const double& a) { return sigmoid(a); });
12}
13
14double accuracy(const Matrix<double>& predictions, const Matrix<double>& ground_truth) {
15 return (double)Corr(predictions, ground_truth) / predictions.rows();
16}
Definition: Matrix.h:42
size_t rows() const
Definition: Matrix.h:193
Matrix< T > Apply(const std::function< T(T)> &fun) const
Definition: Matrix.h:375
double relu(const double &in)
Definition: utils.h:6
double accuracy(const Matrix< double > &predictions, const Matrix< double > &ground_truth)
Definition: utils.h:14
Matrix< double > Sigmoid(const Matrix< double > &in)
Definition: utils.h:9
double sigmoid(const double &in)
Definition: utils.h:7
size_t Corr(const Matrix< T > &A, const Matrix< T > &B)
Definition: matrix_utils.h:103