24 template<
typename AReal>
33 for (
size_t i = 0; i <
m; i++) {
34 for (
size_t j = 0; j <
n; j++) {
35 AReal dY = (
Y(i,j) -
output(i,j));
39 result /= (AReal) (m * n);
44 template<
typename AReal>
54 dY *= - 2.0 / ((AReal) (m*n));
58 template<
typename AReal>
67 for (
size_t i = 0; i <
m; i++) {
68 for (
size_t j = 0; j <
n; j++) {
74 result /= - (AReal) (m * n);
79 template<
typename AReal>
88 AReal
norm = 1.0 / ((AReal) (m * n));
89 for (
size_t i = 0; i <
m; i++)
91 for (
size_t j = 0; j <
n; j++)
95 dY(i,j) = norm * (sig -
y);
101 template<
typename AReal>
110 for (
size_t i = 0; i <
m; i++) {
112 for (
size_t j = 0; j <
n; j++) {
115 for (
size_t j = 0; j <
n; j++) {
124 template<
typename AReal>
132 AReal
norm = 1.0 /
m ;
134 for (
size_t i = 0; i <
m; i++)
138 for (
size_t j = 0; j <
n; j++) {
142 for (
size_t j = 0; j <
n; j++) {
143 dY(i,j) = norm * (
exp(
output(i,j)) / sum * sumY -
Y(i,j));
static void MeanSquaredErrorGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output)
static long int sum(long int i)
static void SoftmaxCrossEntropyGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output)
static void CrossEntropyGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output)
void Minus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix summation. Create a matrix C such that C = A - B.
static AReal SoftmaxCrossEntropy(const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output)
Softmax transformation is implicitly applied, thus output should hold the linear activations of the l...
static AReal CrossEntropy(const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output)
Sigmoid transformation is implicitly applied, thus output should hold the linear activations of the l...
Abstract ClassifierFactory template that handles arbitrary types.
static AReal MeanSquaredError(const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output)
double norm(double *x, double *p)