11 static double cmpLoss(
const Eigen::MatrixXd &o,
const Eigen::MatrixXd &y) {
12 Eigen::MatrixXd cMatrix = y.array() * o.array().log();
14 return -cMatrix.sum();
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();