def test_softmax():
 def softmax(values):
  m = np.max(values)
  e = np.exp((values - m))
  return (e / np.sum(e))
 x = K.placeholder(ndim=2)
 f = K.function([x], [activations.softmax(x)])
 test_values = get_standard_values()
 result = f([test_values])[0]
 expected = softmax(test_values)
 assert_allclose(result, expected, rtol=1e-05)

def test_softmax ( ) : def softmax ( values ) : m = np . max ( values ) e = np . exp ( ( values - m ) ) return ( e / np . sum ( e ) ) x = K . placeholder ( ndim = 2 ) f = K . function ( [ x ] , [ activations . softmax ( x ) ] ) test_values = get_standard_values ( ) result = f ( [ test_values ] ) [ 0 ] expected = softmax ( test_values ) assert_allclose ( result , expected , rtol = 1e-05 )
test using a reference implementation of softmax .