(w_quantized, w_min, w_max)
return (w_min +
          w_quantized.astype(np.float64) / np.power(2, bits) * (w_max - w_min))
Simulate weight de-quantization.

  Args:
    w: (a numpy.ndarray) The weight to be quantized.
    bits: (int) number of bits used for the quantization: 8 or 16.

  Returns:
    A tuple with three elements:
      w_quantized: the quantized version of w, represented as an uint8-
        or uint16-type numpy.ndarray.
      w_min: Minimum value of w, required for dequantization.
      w_max: Maximum value of w, required for dequantization.
Simulate weight de-quantization.
Simulate weight de - quantization .
def dequantize(w_quantized, w_min, w_max):
  """
  Simulate weight de-quantization.

  Args:
    w: (a numpy.ndarray) The weight to be quantized.
    bits: (int) number of bits used for the quantization: 8 or 16.

  Returns:
    A tuple with three elements:
      w_quantized: the quantized version of w, represented as an uint8-
        or uint16-type numpy.ndarray.
      w_min: Minimum value of w, required for dequantization.
      w_max: Maximum value of w, required for dequantization.
  """
  if w_quantized.dtype == np.uint8:
    bits = 8
  elif w_quantized.dtype == np.uint16:
    bits = 16
  else:
    raise ValueError(
        'Unsupported dtype in quantized values: %s' % w_quantized.dtype)
  return (w_min +
          w_quantized.astype(np.float64) / np.power(2, bits) * (w_max - w_min))
def dequantize ( w_quantized , w_min , w_max ) : if w_quantized . dtype == np . uint8 : bits = 8 elif w_quantized . dtype == np . uint16 : bits = 16 else : raise ValueError ( 'Unsupported dtype in quantized values: %s' % w_quantized . dtype ) return ( w_min + w_quantized . astype ( np . float64 ) / np . power ( 2 , bits ) * ( w_max - w_min ) )