NeuralNet 1.0
Loading...
Searching...
No Matches
Quadratic.hpp
1#pragma once
2
3#include "Loss.hpp"
4#include "utils/Functions.hpp"
5
6namespace NeuralNet {
10class Quadratic : public Loss {
11 public:
12 static double cmpLoss(const Eigen::MatrixXd &o, const Eigen::MatrixXd &y) {
13 Eigen::MatrixXd cMatrix = o.array() - y.array();
14 cMatrix = cMatrix.unaryExpr(&sqr);
15
16 return cMatrix.sum();
17 };
18
19 static Eigen::MatrixXd cmpLossGrad(const Eigen::MatrixXd &yHat,
20 const Eigen::MatrixXd &y) {
21 assert(yHat.rows() == y.rows());
22 return (yHat.array() - y.array()).matrix() * 2;
23 };
24};
25} // namespace NeuralNet
Definition Loss.hpp:6
Definition Quadratic.hpp:10