Skip to content

Commit

Permalink
Re-enable tanh and sigmoid tests for C++ ONNX parser (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewDaggitt authored Feb 16, 2024
1 parent 73927a8 commit 571748e
Showing 1 changed file with 15 additions and 31 deletions.
46 changes: 15 additions & 31 deletions src/input_parsers/tests/Test_OnnxParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,42 +359,26 @@ class OnnxParserTestSuite : public CxxTest::TestSuite
return 1.0 / ( 1.0 + exp( -value ) );
}

// Disabled as there appears to be a bug in Marabou main.
// https://github.com/NeuralNetworkVerification/Marabou/issues/638
//
// void test_sigmoid()
// {
// Vector<double> input = {
// -2, 0,
// 1, 3.5
// };
// Vector<double> output = {
// sigmoid_fn(-2), sigmoid_fn(0),
// sigmoid_fn(1), sigmoid_fn(3.5)
// };
// run_test("sigmoid", input, output);
// }
void test_sigmoid()
{
Vector<double> input = { -2, 0, 1, 3.5 };
Vector<double> output = {
sigmoid_fn( -2 ), sigmoid_fn( 0 ), sigmoid_fn( 1 ), sigmoid_fn( 3.5 )
};
run_test( "sigmoid", input, output );
}

double tanh_fn( double value )
{
return ( exp( 2 * value ) - 1 ) / ( exp( 2 * value ) - 1 );
return 2 * sigmoid_fn( 2 * value ) - 1;
}

// Disabled as there appears to be a bug in Marabou main.
// https://github.com/NeuralNetworkVerification/Marabou/issues/638
//
// void test_tanh()
// {
// Vector<double> input = {
// -2, 0,
// 1, 3.5
// };
// Vector<double> output = {
// tanh_fn(-2), tanh_fn(0),
// tanh_fn(1), tanh_fn(3.5)
// };
// run_test("tanh", input, output);
// }
void test_tanh()
{
Vector<double> input = { -2, 0, 1, 3.5 };
Vector<double> output = { tanh_fn( -2 ), tanh_fn( 0 ), tanh_fn( 1 ), tanh_fn( 3.5 ) };
run_test( "tanh", input, output );
}

void test_cast_int_to_float()
{
Expand Down

0 comments on commit 571748e

Please sign in to comment.