Skip to content

Commit

Permalink
Add another test in the hope of triggering more corner cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescarni committed Nov 12, 2023
1 parent 109743a commit da1288d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/expression_diff_tensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <heyoka/llvm_state.hpp>
#include <heyoka/math/prod.hpp>
#include <heyoka/math/sum.hpp>
#include <heyoka/math/tanh.hpp>
#include <heyoka/model/ffnn.hpp>
#include <heyoka/model/fixed_centres.hpp>
#include <heyoka/s11n.hpp>

Expand Down Expand Up @@ -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();
}

0 comments on commit da1288d

Please sign in to comment.