23 #ifndef TMVA_TEST_DNN_TEST_ACTIVATION_FUNCTIONS 24 #define TMVA_TEST_DNN_TEST_ACTIVATION_FUNCTIONS 41 template <
typename Architecture>
43 ->
typename Architecture::Scalar_t
45 using Matrix_t =
typename Architecture::Matrix_t;
48 for (
size_t i = 0; i < ntests; i++) {
49 size_t m = rand() % 100 + 1;
50 size_t n = rand() % 100 + 1;
60 maximumError = std::max(error, maximumError);
67 template <
typename Architecture>
69 ->
typename Architecture::Scalar_t
71 using Matrix_t =
typename Architecture::Matrix_t;
74 for (
size_t i = 0; i < ntests; i++) {
75 size_t m = rand() % 100 + 1;
76 size_t n = rand() % 100 + 1;
80 Matrix_t AArch(ARef), BArch(BRef);
88 maximumError = std::max(error, maximumError);
100 template <
typename Architecture>
102 ->
typename Architecture::Scalar_t
104 using Matrix_t =
typename Architecture::Matrix_t;
107 for (
size_t i = 0; i < ntests; i++) {
108 size_t m = rand() % 100 + 1;
109 size_t n = rand() % 100 + 1;
113 Matrix_t AArch(ARef);
120 maximumError = std::max(error, maximumError);
127 template <
typename Architecture>
129 ->
typename Architecture::Scalar_t
131 using Matrix_t =
typename Architecture::Matrix_t;
134 for (
size_t i = 0; i < ntests; i++) {
135 size_t m = rand() % 100 + 1;
136 size_t n = rand() % 100 + 1;
140 Matrix_t AArch(ARef), BArch(BRef);
143 applyMatrix(ARef, [](
double x){
return x > 0.0 ? 1.0 : 0.0;});
147 maximumError = std::max(error, maximumError);
159 template <
typename Architecture>
161 ->
typename Architecture::Scalar_t
163 using Matrix_t =
typename Architecture::Matrix_t;
166 for (
size_t i = 0; i < ntests; i++) {
167 size_t m = rand() % 100 + 1;
168 size_t n = rand() % 100 + 1;
172 Matrix_t AArch(ARef);
179 maximumError = std::max(error, maximumError);
186 template <
typename Architecture>
188 ->
typename Architecture::Scalar_t
190 using Matrix_t =
typename Architecture::Matrix_t;
193 for (
size_t i = 0; i < ntests; i++) {
194 size_t m = rand() % 100 + 1;
195 size_t n = rand() % 100 + 1;
199 Matrix_t AArch(ARef), BArch(BRef);
204 return sig * (1.0 - sig);
209 maximumError = std::max(error, maximumError);
221 template <
typename Architecture>
223 ->
typename Architecture::Scalar_t
225 using Matrix_t =
typename Architecture::Matrix_t;
228 for (
size_t i = 0; i < ntests; i++) {
229 size_t m = rand() % 100 + 1;
230 size_t n = rand() % 100 + 1;
234 Matrix_t AArch(ARef);
241 maximumError = std::max(error, maximumError);
248 template <
typename Architecture>
250 ->
typename Architecture::Scalar_t
252 using Matrix_t =
typename Architecture::Matrix_t;
255 for (
size_t i = 0; i < ntests; i++) {
256 size_t m = rand() % 100 + 1;
257 size_t n = rand() % 100 + 1;
261 Matrix_t AArch(ARef), BArch(BRef);
271 maximumError = std::max(error, maximumError);
283 template <
typename Architecture>
285 ->
typename Architecture::Scalar_t
287 using Matrix_t =
typename Architecture::Matrix_t;
290 for (
size_t i = 0; i < ntests; i++) {
291 size_t m = rand() % 100 + 1;
292 size_t n = rand() % 100 + 1;
296 Matrix_t AArch(ARef);
303 maximumError = std::max(error, maximumError);
310 template <
typename Architecture>
312 ->
typename Architecture::Scalar_t
314 using Matrix_t =
typename Architecture::Matrix_t;
317 for (
size_t i = 0; i < ntests; i++) {
318 size_t m = rand() % 100 + 1;
319 size_t n = rand() % 100 + 1;
323 Matrix_t AArch(ARef), BArch(BRef);
327 return (x < 0) ? -1.0 : 1.0;
332 maximumError = std::max(error, maximumError);
344 template <
typename Architecture>
346 ->
typename Architecture::Scalar_t
348 using Matrix_t =
typename Architecture::Matrix_t;
351 for (
size_t i = 0; i < ntests; i++) {
352 size_t m = rand() % 100 + 1;
353 size_t n = rand() % 100 + 1;
357 Matrix_t AArch(ARef);
364 maximumError = std::max(error, maximumError);
371 template <
typename Architecture>
373 ->
typename Architecture::Scalar_t
375 using Matrix_t =
typename Architecture::Matrix_t;
378 for (
size_t i = 0; i < ntests; i++) {
379 size_t m = rand() % 100 + 1;
380 size_t n = rand() % 100 + 1;
384 Matrix_t AArch(ARef), BArch(BRef);
389 return 1.0 / (y *
y);
394 maximumError = std::max(error, maximumError);
406 template <
typename Architecture>
408 ->
typename Architecture::Scalar_t
410 using Matrix_t =
typename Architecture::Matrix_t;
413 for (
size_t i = 0; i < ntests; i++) {
414 size_t m = rand() % 100 + 1;
415 size_t n = rand() % 100 + 1;
419 Matrix_t AArch(ARef);
426 maximumError = std::max(error, maximumError);
433 template <
typename Architecture>
435 ->
typename Architecture::Scalar_t
437 using Matrix_t =
typename Architecture::Matrix_t;
440 for (
size_t i = 0; i < ntests; i++) {
441 size_t m = rand() % 100 + 1;
442 size_t n = rand() % 100 + 1;
446 Matrix_t AArch(ARef), BArch(BRef);
453 maximumError = std::max(error, maximumError);
auto maximumRelativeError(const Matrix1 &X, const Matrix2 &Y) -> decltype(X(0, 0))
Compute the maximum, element-wise relative error of the matrices X and Y normalized by the element of...
auto testSigmoid(size_t ntests) -> typename Architecture::Scalar_t
Test application of Sigmoid function to matrix.
void randomMatrix(AMatrix &X)
Fill matrix with random, Gaussian-distributed values.
void applyMatrix(AMatrix &X, F f)
Apply functional to each element in the matrix.
auto testGauss(size_t ntests) -> typename Architecture::Scalar_t
Test application of Gauss activation function to matrix.
auto testSymmetricReluDerivative(size_t ntests) -> typename Architecture::Scalar_t
Test computation of the first derivative of the symmetric ReLU function.
auto testReluDerivative(size_t ntests) -> typename Architecture::Scalar_t
Test computation of the first derivative of the ReLU function.
auto testSoftSign(size_t ntests) -> typename Architecture::Scalar_t
Test application of symmetric soft sign function to matrix.
auto testSymmetricRelu(size_t ntests) -> typename Architecture::Scalar_t
Test application of symmetric ReLU function to matrix.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
auto testGaussDerivative(size_t ntests) -> typename Architecture::Scalar_t
Test computation of the first derivative of the Gauss activation function.
auto testTanh(size_t ntests) -> typename Architecture::Scalar_t
Test application of tanh function to matrix.
auto testSoftSignDerivative(size_t ntests) -> typename Architecture::Scalar_t
Test computation of the first derivative of the soft sign function.
auto testTanhDerivative(size_t ntests) -> typename Architecture::Scalar_t
Test computation of the first derivative of the tanh function.
auto testSigmoidDerivative(size_t ntests) -> typename Architecture::Scalar_t
Test computation of the first derivative of the ReLU function.
auto testRelu(size_t ntests) -> typename Architecture::Scalar_t
Test application of ReLU function to matrix.
auto testIdentityDerivative(size_t ntests) -> typename Architecture::Scalar_t
Test computation of the first derivative of the identity function.
auto testIdentity() -> typename Architecture_t::Scalar_t
Test the data loader by loading identical input and output data, running it through an identity neura...