def tanh_cutoff(x, cutoff):
 y = tf.tanh(x)
 if (cutoff < 1.01):
  return y
 d = ((cutoff - 1.0) / 2.0)
 return tf.minimum(1.0, tf.maximum((-1.0), ((1.0 + d) * y)))

def tanh_cutoff ( x , cutoff ) : y = tf . tanh ( x ) if ( cutoff < 1.01 ) : return y d = ( ( cutoff - 1.0 ) / 2.0 ) return tf . minimum ( 1.0 , tf . maximum ( ( - 1.0 ) , ( ( 1.0 + d ) * y ) ) )
tanh with cutoff .