24 template <
typename AReal>
28 output.
MultT(input, weights);
31 template <
typename AReal>
34 for (
size_t i = 0; i < (size_t) output.
GetNrows(); i++) {
35 for (
size_t j = 0; j < (size_t) output.
GetNcols(); j++) {
36 output(i,j) += biases(j,0);
41 template <
typename AReal>
49 for (
size_t i = 0; i < (size_t) df.
GetNrows(); i++) {
50 for (
size_t j = 0; j < (size_t) df.
GetNcols(); j++) {
51 df(i,j) *= activation_gradients(i,j);
57 activation_gradients_backward.
Mult(df, weights);
62 weight_gradients.
TMult(df, activations_backward);
67 for (
size_t j = 0; j < (size_t) df.
GetNcols(); j++) {
69 for (
size_t i = 0; i < (size_t) df.
GetNrows(); i++) {
72 bias_gradients(j,0) =
sum;
77 template <
typename AReal>
80 for (
size_t i = 0; i < (size_t) A.
GetNrows(); i++) {
81 for (
size_t j = 0; j < (size_t) A.
GetNcols(); j++) {
82 A(i,j) += beta *
B(i,j);
87 template <
typename AReal>
93 template <
typename AReal>
static long int sum(long int i)
double beta(double x, double y)
Calculates the beta function.
Int_t GetNoElements() const
void MultT(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B^T.
static void Copy(TMatrixT< Scalar_t > &A, const TMatrixT< Scalar_t > &B)
void TMult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
Create a matrix C such that C = A' * B.
static void Backward(TMatrixT< Scalar_t > &activationGradientsBackward, TMatrixT< Scalar_t > &weightGradients, TMatrixT< Scalar_t > &biasGradients, TMatrixT< Scalar_t > &df, const TMatrixT< Scalar_t > &activationGradients, const TMatrixT< Scalar_t > &weights, const TMatrixT< Scalar_t > &activationBackward)
Perform the complete backward propagation step.
static void SumColumns(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
Sum columns of (m x n) matrixx A and write the results into the first m elements in A...
static void ScaleAdd(TMatrixT< Scalar_t > &A, const TMatrixT< Scalar_t > &B, Scalar_t beta=1.0)
Adds a the elements in matrix B scaled by c to the elements in the matrix A.
Abstract ClassifierFactory template that handles arbitrary types.
void Mult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
General matrix multiplication. Create a matrix C such that C = A * B.
static void MultiplyTranspose(TMatrixT< Scalar_t > &output, const TMatrixT< Scalar_t > &input, const TMatrixT< Scalar_t > &weights)
Matrix-multiply input with the transpose of and write the results into output.
static void AddRowWise(TMatrixT< Scalar_t > &output, const TMatrixT< Scalar_t > &biases)
Add the vectors biases row-wise to the matrix output.