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