def hard_sigmoid(x):
 out_dtype = scalar.upgrade_to_float(scalar.Scalar(dtype=x.dtype))[0].dtype
 slope = tensor.constant(0.2, dtype=out_dtype)
 shift = tensor.constant(0.5, dtype=out_dtype)
 x = ((x * slope) + shift)
 x = tensor.clip(x, 0, 1)
 return x

def hard_sigmoid ( x ) : out_dtype = scalar . upgrade_to_float ( scalar . Scalar ( dtype = x . dtype ) ) [ 0 ] . dtype slope = tensor . constant ( 0.2 , dtype = out_dtype ) shift = tensor . constant ( 0.5 , dtype = out_dtype ) x = ( ( x * slope ) + shift ) x = tensor . clip ( x , 0 , 1 ) return x
an approximation of sigmoid .