From da1288d0b84b8bc4b119af614199a3fd1da7ad76 Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Sun, 12 Nov 2023 12:01:21 +0100 Subject: [PATCH] Add another test in the hope of triggering more corner cases. --- test/expression_diff_tensors.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/expression_diff_tensors.cpp b/test/expression_diff_tensors.cpp index 0cba38a63..4cb91140c 100644 --- a/test/expression_diff_tensors.cpp +++ b/test/expression_diff_tensors.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -700,3 +702,18 @@ TEST_CASE("jacobian") REQUIRE(jac == std::vector{1_dbl, 1_dbl, 1_dbl, -1_dbl, -1_dbl, -1_dbl}); } } + +// A test on a neural network. No REQUIREs, +// for this test we rely on the internal assertions +// in debug mode. +TEST_CASE("nn test") +{ + const auto nn_layer = 50u; + + auto [x, y] = make_vars("x", "y"); + auto ffnn = model::ffnn(kw::inputs = {x, y}, kw::nn_hidden = {nn_layer, nn_layer, nn_layer}, kw::n_out = 2, + kw::activations = {heyoka::tanh, heyoka::tanh, heyoka::tanh, heyoka::tanh}); + + auto dt = diff_tensors(ffnn, kw::diff_args = diff_args::params); + auto dNdtheta = dt.get_jacobian(); +}