(input_node)
return [
      create_constant_node(
          input_node.name,
          tensor_value_rounded,
          dtypes.float32,
          shape=tensor_shape_list)
  ]
Returns a replacement node for input_node containing bucketed floats.
Returns a replacement node for input_node containing bucketed floats.
Returns a replacement node for input_node containing bucketed floats .
def quantize_weight_rounded(input_node):
  """Returns a replacement node for input_node containing bucketed floats."""
  input_tensor = input_node.attr["value"].tensor
  tensor_value = tensor_util.MakeNdarray(input_tensor)
  shape = input_tensor.tensor_shape
  # Currently, the parameter FLAGS.bitdepth is used to compute the
  # number of buckets as 1 << FLAGS.bitdepth, meaning the number of
  # buckets can only be a power of 2.
  # This could be fixed by introducing a new parameter, num_buckets,
  # which would allow for more flexibility in chosing the right model
  # size/accuracy tradeoff. But I didn't want to add more parameters
  # to this script than absolutely necessary.
  num_buckets = 1 << FLAGS.bitdepth
  tensor_value_rounded = quantize_array(tensor_value, num_buckets)
  tensor_shape_list = tensor_util.TensorShapeProtoToList(shape)
  return [
      create_constant_node(
          input_node.name,
          tensor_value_rounded,
          dtypes.float32,
          shape=tensor_shape_list)
  ]
def quantize_weight_rounded ( input_node ) : input_tensor = input_node . attr [ "value" ] . tensor tensor_value = tensor_util . MakeNdarray ( input_tensor ) shape = input_tensor . tensor_shape # Currently, the parameter FLAGS.bitdepth is used to compute the # number of buckets as 1 << FLAGS.bitdepth, meaning the number of # buckets can only be a power of 2. # This could be fixed by introducing a new parameter, num_buckets, # which would allow for more flexibility in chosing the right model # size/accuracy tradeoff. But I didn't want to add more parameters # to this script than absolutely necessary. num_buckets = 1 << FLAGS . bitdepth tensor_value_rounded = quantize_array ( tensor_value , num_buckets ) tensor_shape_list = tensor_util . TensorShapeProtoToList ( shape ) return [ create_constant_node ( input_node . name , tensor_value_rounded , dtypes . float32 , shape = tensor_shape_list ) ]