示例#1
0
def test_dtanh_matrix():
    tensor_shape = [random.randint(1, 10) for _ in range(2)]

    helpers.check_gradient(lambda X: calculate.tanh(X),
                           lambda X: calculate.dtanh(calculate.tanh(X)),
                           f_arg_tensor=numpy.random.random(tensor_shape),
                           f_shape='lin')
示例#2
0
def test_dtanh():
    helpers.check_gradient(calculate.tanh,
                           lambda x: calculate.dtanh(calculate.tanh(x)),
                           f_shape='lin')
示例#3
0
def test_tanh():
    assert helpers.approx_equal(
        calculate.tanh(numpy.array([-1.0, 0.0, 0.5, 1.0])),
        [-0.761594, 0.0, 0.462117, 0.761594])
示例#4
0
 def __call__(self, input_vec):
     return calculate.tanh(input_vec)