class_docstr: Class to implement highly efficient vectorised look-ups.
  
  We do not utilise looping for that purpose, instead we `smartly` reshape and
  tile arrays. The trade-off is that we are potentially using way more memory
  than we would have if looping is used.
  
  Each class that inherits from this class is supposed to implement a
  particular lookup function for a certain shape.
  
  For example, look-ups for 2D table will be different in the case of 3D.
class_docstr_tok: ["Class","to","implement","highly","efficient","vectorised","look-ups",".","We","do","not","utilise","looping","for","that","purpose",",","instead","we","`","smartly","`","reshape","and","tile","arrays",".","The","trade-off","is","that","we","are","potentially","using","way","more","memory","than","we","would","have","if","looping","is","used",".","Each","class","that","inherits","from","this","class","is","supposed","to","implement","a","particular","lookup","function","for","a","certain","shape",".","For","example",",","look-ups","for","2D","table","will","be","different","in","the","case","of","3D","."]
docstr: Generating clustered tensors.
  
  For generating clustered tensors we will need two things: cluster
  centroids and the final shape tensor must have.
  
  Args:
    clusters_centroids: An array of shape (N,) that contains initial values of
      clusters centroids.
    cluster_gradient_aggregation: An enum that specify the aggregation method
      of the cluster gradient.
    data_format: To be used in cluster_per_channel to ensure the weight
      kernel is permuted properly when updating the weights and calculating
      gradients
docstr_tok: ["Generating","clustered","tensors",".","For","generating","clustered","tensors","we","will","need","two","things",":","cluster","centroids","and","the","final","shape","tensor","must","have",".","Args",":","clusters_centroids",":","An","array","of","shape","(","N",",",")","that","contains","initial","values","of","clusters","centroids",".","cluster_gradient_aggregation",":","An","enum","that","specify","the","aggregation","method","of","the","cluster","gradient",".","data_format",":","To","be","used","in","cluster_per_channel","to","ensure","the","weight","kernel","is","permuted","properly","when","updating","the","weights","and","calculating","gradients"]
code: def __init__(
      self,
      clusters_centroids,
      cluster_gradient_aggregation=GradientAggregation.SUM,
      data_format=None,
  ):
      """Generating clustered tensors.
  
      For generating clustered tensors we will need two things: cluster
      centroids and the final shape tensor must have.
  
      Args:
        clusters_centroids: An array of shape (N,) that contains initial values of
          clusters centroids.
        cluster_gradient_aggregation: An enum that specify the aggregation method
          of the cluster gradient.
        data_format: To be used in cluster_per_channel to ensure the weight
          kernel is permuted properly when updating the weights and calculating
          gradients
      """
      if not isinstance(clusters_centroids, tf.Variable):
          raise ValueError(
              "clusters_centroids should be a tf.Variable."
          )
  
      self.cluster_centroids = clusters_centroids
      self.cluster_gradient_aggregation = cluster_gradient_aggregation
      self.data_format = data_format
  
file_path: model-optimization/tensorflow_model_optimization/python/core/clustering/keras/clustering_algorithm.py
imports: import abc
  import six
  import tensorflow
  from tensorflow_model_optimization.python.core.clustering.keras.cluster_config import GradientAggregation
label_desc: Use image node_id 1 to create a new ClusteringAlgorithm object from inherited base classes: object with example: obj = ClusteringAlgorithm(clusters_centroids, cluster_gradient_aggregation, data_format)