From 4c75252f25eec9f787dd009566607fd21d354548 Mon Sep 17 00:00:00 2001 From: Mark Neumann Date: Wed, 21 Jun 2017 12:49:21 -0700 Subject: [PATCH] fix initial test values to avoid numerical instability --- tensorflow/cc/gradients/nn_grad_test.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tensorflow/cc/gradients/nn_grad_test.cc b/tensorflow/cc/gradients/nn_grad_test.cc index de6b6140374..daa87546ec0 100644 --- a/tensorflow/cc/gradients/nn_grad_test.cc +++ b/tensorflow/cc/gradients/nn_grad_test.cc @@ -58,10 +58,16 @@ TEST_F(NNGradTest, SoftmaxGrad) { } TEST_F(NNGradTest, LogSoftmaxGrad) { - TensorShape shape({32, 10}); + TensorShape shape({5, 3}); auto x = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(shape)); auto y = LogSoftmax(scope_, x); - RunTest(x, shape, y, shape); + // Avoid numerical instability when computing finite differences. + Tensor x_init_value = test::AsTensor( + {-0.9f, -0.7f, -0.5f, -0.3f, -0.1f, + 0.1f, 0.3f, 0.5f, 0.7f, 0.8f, + -0.1f, 0.1f, 0.1f, 0.1f, 1.2f}, + {5, 3}); + RunTest(x, x_init_value, y, shape); } TEST_F(NNGradTest, ReluGrad) {