Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion tests/keras/activations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def softplus(x):
expected = softplus(test_values)
assert_allclose(result, expected, rtol=1e-05)


def test_softsign():
"""Test using a reference softsign implementation.
"""
Expand Down Expand Up @@ -153,6 +152,23 @@ def ref_sigmoid(x):
expected = sigmoid(test_values)
assert_allclose(result, expected, rtol=1e-05)

def test_mish():
"""Test mish implementation.
"""
def ref_mish(x):
softplus = np.log(np.ones_like(x) + np.exp(x))
tanh_softplus_x = (np.exp(softplus) - np.exp(-softplus))/(np.exp(softplus) + np.exp(-softplus))
return x*tanh_softplus_x

mish = np.vectorize(ref_mish)

x = K.placeholder(ndim=2)
f = K.function([x], [activations.mish(x)])
test_values = get_standard_values()

result = f([test_values])[0]
expected = mish(test_values)
assert_allclose(result, expected, rtol=1e-05)

def test_hard_sigmoid():
"""Test using a reference hard sigmoid implementation.
Expand Down