def test_tanh(self): a = Variable(1.5) c = a.tanh() c.backward() self.assertAlmostEqual(a.d.value, 1 - tanh(1.5)**2)
def test_tanh(self): a = Variable(1.5) c = a.tanh() self.assertAlmostEqual(c.value, tanh(1.5))
def test_tanh2(self): a = Variable(0) c = a.tanh() self.assertAlmostEqual(c.value, 0.0)
def test_tanh2(self): a = Variable(0) c = a.tanh() c.backward() self.assertAlmostEqual(a.d.value, 1.0)