def quantize(t, quant_scale, max_value=1.0):
 t = tf.minimum(max_value, tf.maximum(t, (- max_value)))
 big = ((quant_scale * (t + max_value)) + 0.5)
 with tf.get_default_graph().gradient_override_map({'Floor': 'CustomIdG'}):
  res = ((tf.floor(big) / quant_scale) - max_value)
 return res

def quantize ( t , quant_scale , max_value = 1.0 ) : t = tf . minimum ( max_value , tf . maximum ( t , ( - max_value ) ) ) big = ( ( quant_scale * ( t + max_value ) ) + 0.5 ) with tf . get_default_graph ( ) . gradient_override_map ( { 'Floor' : 'CustomIdG' } ) : res = ( ( tf . floor ( big ) / quant_scale ) - max_value ) return res
quantize a tensor t with each element in [-max_value .