def hard_sigmoid(x):
    # Use the same dtype as determined by "upgrade_to_float",
    # and perform computation in that dtype.
    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


# @opt.register_uncanonicalize
An approximation of sigmoid.
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/tensor/nnet/sigm.py/hard_sigmoid