from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from caffe2.python import core
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu

import unittest


class TestSoftplus(hu.HypothesisTestCase):

    @given(X=hu.tensor(),
           **hu.gcs)
    def test_softplus(self, X, gc, dc):
        op = core.CreateOperator("Softplus", ["X"], ["Y"])
        self.assertDeviceChecks(dc, op, [X], [0])
        self.assertGradientChecks(gc, op, [X], 0, [0], stepsize=0.0005)


if __name__ == "__main__":
    unittest.main()

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from caffe2.python import core
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu

import unittest


class TestSoftplus(hu.HypothesisTestCase):

    @given(X=hu.tensor(),
           **hu.gcs)
    def test_softplus(self, X, gc, dc):
        op = core.CreateOperator("Softplus", ["X"], ["Y"])
        self.assertDeviceChecks(dc, op, [X], [0])
        self.assertGradientChecks(gc, op, [X], 0, [0])


if __name__ == "__main__":
    unittest.main()

Fix gradient checking for softplus op
Fix gradient checking for softplus op

Summary:
kmatzen why did you set the stepsize in https://github.com/caffe2/caffe2/commit/ff84e7dea6e118710859d62a7207c06b87ae992e?

The test is flaky before this change. Solid afterwards.
Closes https://github.com/caffe2/caffe2/pull/841

Differential Revision: D5292112

Pulled By: akyrola

fbshipit-source-id: c84715261194ff047606d4ec659b7f89dac3cbb1

  from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  
  from caffe2.python import core
  from hypothesis import given
  import caffe2.python.hypothesis_test_util as hu
  
  import unittest
  
  
  class TestSoftplus(hu.HypothesisTestCase):
  
      @given(X=hu.tensor(),
             **hu.gcs)
      def test_softplus(self, X, gc, dc):
          op = core.CreateOperator("Softplus", ["X"], ["Y"])
          self.assertDeviceChecks(dc, op, [X], [0])
-         self.assertGradientChecks(gc, op, [X], 0, [0], stepsize=0.0005)
+         self.assertGradientChecks(gc, op, [X], 0, [0])
  
  
  if __name__ == "__main__":
      unittest.main()
  
Fix gradient checking for softplus op
## Code Before:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from caffe2.python import core
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu

import unittest


class TestSoftplus(hu.HypothesisTestCase):

    @given(X=hu.tensor(),
           **hu.gcs)
    def test_softplus(self, X, gc, dc):
        op = core.CreateOperator("Softplus", ["X"], ["Y"])
        self.assertDeviceChecks(dc, op, [X], [0])
        self.assertGradientChecks(gc, op, [X], 0, [0], stepsize=0.0005)


if __name__ == "__main__":
    unittest.main()

## Instruction:
Fix gradient checking for softplus op
## Code After:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from caffe2.python import core
from hypothesis import given
import caffe2.python.hypothesis_test_util as hu

import unittest


class TestSoftplus(hu.HypothesisTestCase):

    @given(X=hu.tensor(),
           **hu.gcs)
    def test_softplus(self, X, gc, dc):
        op = core.CreateOperator("Softplus", ["X"], ["Y"])
        self.assertDeviceChecks(dc, op, [X], [0])
        self.assertGradientChecks(gc, op, [X], 0, [0])


if __name__ == "__main__":
    unittest.main()
