29template<
typename Real_t>
36 for(
size_t i = 0; i<
m; i++)
38 for(
size_t j=0; j<
n; j++)
40 A(i, j) += biases(i, 0);
47template <
typename Real_t>
55 for (
size_t i = 0; i < (size_t)fVBiases.
GetNrows(); i++)
57 for (
size_t j = 0; j < (size_t)fVBiases.
GetNcols(); j++) {
58 VBiasError(i, j) =
x(i, j) - z(i, j);
59 fVBiases(i, j) += learningRate * VBiasError(i, j) / fBatchSize;
67 HBiasError(i, 0) += fWeights(i, j) * VBiasError(j, 0);
69 HBiasError(i, 0) *=
y(i, 0) * (1 -
y(i, 0));
70 fHBiases(i, 0) += learningRate * HBiasError(i, 0) / fBatchSize;
76 fWeights(i, j) += learningRate * (HBiasError(i, 0) * tildeX(j, 0) +
77 VBiasError(j, 0) *
y(i, 0)) / fBatchSize;
84template<
typename Real_t>
92 for (
size_t i = 0; i <
m; i++) {
93 for (
size_t j = 0; j <
n; j++) {
98 for (
size_t i = 0; i <
m; i++) {
99 for (
size_t j = 0; j <
n; j++) {
100 A(i, j) =
exp(A(i, j)) /
sum;
107template <
typename Real_t>
111 for(
size_t i=0; i< (size_t)input.
GetNrows(); i++)
113 for(
size_t j=0; j<(size_t)input.
GetNcols(); j++ )
116 if ((
size_t)((rand() / (RAND_MAX + 1.0)) * 100) %
117 ((
size_t)(corruptionLevel * 10)) ==
120 corruptedInput(i, j) = 0;
124 corruptedInput(i, j) = input(i, j);
133template <
typename Real_t>
142 for (
size_t i = 0; i <
m; i++) {
143 compressedInput(i, 0) = 0;
144 for (
size_t j = 0; j <
a; j++) {
145 compressedInput(i, 0) =
146 compressedInput(i, 0) + (Weights(i, j) * input(j, 0));
151template <
typename Real_t>
155 for (
size_t i=0; i<(size_t)reconstructedInput.
GetNrows(); i++)
157 reconstructedInput(i, 0) = 0;
158 for(
size_t j=0; j<(size_t)compressedInput.
GetNrows();j++)
160 reconstructedInput(i, 0) += fWeights(j, i) * compressedInput(j, 0);
170template<
typename Real_t>
178 for(
size_t i= 0; i <
m; i++)
181 for(
size_t j=0; j <
n; j++)
183 p(i, 0) += fWeights(i, j) * input(j, 0);
190template<
typename Real_t>
204 for(
size_t i= 0; i<
m; i++)
206 difference(i, 0) =
output(i, 0) - p(i, 0);
207 for(
size_t j=0; j<
n; j++)
210 learningRate * difference(i, 0) * input(j, 0) / fBatchSize;
213 fBiases(i, 0) += learningRate * difference(i, 0) / fBatchSize;
static void SoftmaxAE(TMatrixT< AReal > &A)
static void EncodeInput(TMatrixT< AReal > &input, TMatrixT< AReal > &compressedInput, TMatrixT< AReal > &Weights)
static void ReconstructInput(TMatrixT< AReal > &compressedInput, TMatrixT< AReal > &reconstructedInput, TMatrixT< AReal > &fWeights)
static void UpdateParams(TMatrixT< AReal > &x, TMatrixT< AReal > &tildeX, TMatrixT< AReal > &y, TMatrixT< AReal > &z, TMatrixT< AReal > &fVBiases, TMatrixT< AReal > &fHBiases, TMatrixT< AReal > &fWeights, TMatrixT< AReal > &VBiasError, TMatrixT< AReal > &HBiasError, AReal learningRate, size_t fBatchSize)
static void UpdateParamsLogReg(TMatrixT< AReal > &input, TMatrixT< AReal > &output, TMatrixT< AReal > &difference, TMatrixT< AReal > &p, TMatrixT< AReal > &fWeights, TMatrixT< AReal > &fBiases, AReal learningRate, size_t fBatchSize)
static void CorruptInput(TMatrixT< AReal > &input, TMatrixT< AReal > &corruptedInput, AReal corruptionLevel)
static void ForwardLogReg(TMatrixT< AReal > &input, TMatrixT< AReal > &p, TMatrixT< AReal > &fWeights)
static void AddBiases(TMatrixT< AReal > &A, const TMatrixT< AReal > &biases)
create variable transformations
static uint64_t sum(uint64_t i)
static void output(int code)