24template <
typename AReal>
33 for (
size_t i = 0;
i <
m;
i++) {
34 for (
size_t j = 0; j <
n; j++) {
36 result += weights(
i, 0) * dY * dY;
44template <
typename AReal>
53 dY *= -2.0 /
static_cast<AReal
>(
m *
n);
55 for (
size_t i = 0;
i <
m;
i++) {
56 for (
size_t j = 0; j <
n; j++) {
57 dY(
i, j) *= weights(
i, 0);
63template <
typename AReal>
72 for (
size_t i = 0;
i <
m;
i++) {
73 AReal
w = weights(
i, 0);
74 for (
size_t j = 0; j <
n; j++) {
75 AReal sig = 1.0 / (1.0 + std::exp(-
output(
i,j)));
76 result +=
w * (Y(
i, j) * std::log(sig) + (1.0 - Y(
i, j)) * std::log(1.0 - sig));
79 result /= -
static_cast<AReal
>(
m *
n);
84template <
typename AReal>
92 AReal norm = 1.0 /
static_cast<AReal
>(
m *
n);
93 for (
size_t i = 0;
i <
m;
i++)
95 AReal
w = weights(
i, 0);
96 for (
size_t j = 0; j <
n; j++)
99 AReal sig = 1.0 / (1.0 + std::exp(-
output(
i,j)));
100 dY(
i, j) = norm *
w * (sig -
y);
106template <
typename AReal>
115 for (
size_t i = 0;
i <
m;
i++) {
117 AReal
w = weights(
i, 0);
118 for (
size_t j = 0; j <
n; j++) {
121 for (
size_t j = 0; j <
n; j++) {
125 result /= -
static_cast<AReal
>(
m);
130template <
typename AReal>
137 AReal norm = 1.0 /
m ;
139 for (
size_t i = 0;
i <
m;
i++)
143 AReal
w = weights(
i, 0);
144 for (
size_t j = 0; j <
n; j++) {
148 for (
size_t j = 0; j <
n; j++) {
149 dY(
i, j) =
w * norm * (exp(
output(
i, j)) /
sum * sumY - Y(
i, j));
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
static void CrossEntropyGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
static AReal SoftmaxCrossEntropy(const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
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, const TMatrixT< AReal > &weights)
Sigmoid transformation is implicitly applied, thus output should hold the linear activations of the l...
static void MeanSquaredErrorGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
static void SoftmaxCrossEntropyGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
static AReal MeanSquaredError(const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
void Minus(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix subtraction. Replace this matrix with C such that C = A - B.
create variable transformations
static uint64_t sum(uint64_t i)