24 template<
typename Scalar_t>
29 output.
MultT(input, weights);
32 template<
typename Scalar_t>
36 for (
size_t i = 0; i < (size_t) output.
GetNrows(); i++) {
37 for (
size_t j = 0; j < (size_t) output.
GetNcols(); j++) {
38 output(i,j) += biases(j,0);
43 template<
typename Scalar_t>
54 for (
size_t i = 0; i < (size_t) df.
GetNrows(); i++) {
55 for (
size_t j = 0; j < (size_t) df.
GetNcols(); j++) {
56 df(i,j) *= activation_gradients(i,j);
62 activation_gradients_backward.
Mult(df, weights);
67 weight_gradients.
TMult(df, activations_backward);
72 for (
size_t j = 0; j < (size_t) df.
GetNcols(); j++) {
74 for (
size_t i = 0; i < (size_t) df.
GetNrows(); i++) {
77 bias_gradients(j,0) =
sum;
82 template<
typename Scalar_t>
87 for (
size_t i = 0; i < (size_t) A.
GetNrows(); i++) {
88 for (
size_t j = 0; j < (size_t) A.
GetNcols(); j++) {
89 A(i,j) += beta *
B(i,j);
94 template<
typename Scalar_t>
static long int sum(long int i)
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 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 AddRowWise(TMatrixT< Scalar_t > &output, const TMatrixT< Scalar_t > &biases)
Add the vectors biases row-wise to the matrix output.
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.
void TMult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
Create a matrix C such that C = A' * B.
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.
static void Copy(TMatrixT< Scalar_t > &A, const TMatrixT< Scalar_t > &B)
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.