def test_hard_sigmoid():
 def ref_hard_sigmoid(x):
  '\n        Reference hard sigmoid with slope and shift values from theano, see\n        https://github.com/Theano/Theano/blob/master/theano/tensor/nnet/sigm.py\n        '
  x = ((x * 0.2) + 0.5)
  z = (0.0 if (x <= 0) else (1.0 if (x >= 1) else x))
  return z
 hard_sigmoid = np.vectorize(ref_hard_sigmoid)
 x = K.placeholder(ndim=2)
 f = K.function([x], [activations.hard_sigmoid(x)])
 test_values = get_standard_values()
 result = f([test_values])[0]
 expected = hard_sigmoid(test_values)
 assert_allclose(result, expected, rtol=1e-05)

def test_hard_sigmoid ( ) : def ref_hard_sigmoid ( x ) : x = ( ( x * 0.2 ) + 0.5 ) z = ( 0.0 if ( x <= 0 ) else ( 1.0 if ( x >= 1 ) else x ) ) return z hard_sigmoid = np . vectorize ( ref_hard_sigmoid ) x = K . placeholder ( ndim = 2 ) f = K . function ( [ x ] , [ activations . hard_sigmoid ( x ) ] ) test_values = get_standard_values ( ) result = f ( [ test_values ] ) [ 0 ] expected = hard_sigmoid ( test_values ) assert_allclose ( result , expected , rtol = 1e-05 )
test using a reference hard sigmoid implementation .