add regression tests

This commit is contained in:
James Bradbury 2019-09-21 01:04:26 -04:00
parent 942d4e7217
commit 9ef53120d2

38
tests/nn_test.py Normal file
View File

@ -0,0 +1,38 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for nn module."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from absl.testing import absltest
from absl.testing import parameterized
import numpy as onp
from jax import test_util as jtu
from jax.test_util import check_grads
from jax import nn
from jax import random
from jax.config import config
config.parse_flags_with_absl()
class NNTest(jtu.JaxTestCase):
def testSoftplusGrad(self):
check_grads(nn.softplus, (1e-8,), 4)
def testSoftplusValue(self):
val = nn.softplus(89.)
self.assertEqual(val, 89.)