parameters: (self)
return_statement: return all_scores, cluster_idx, scores, training_op
docstring: Generate a training graph for kmeans algorithm.
  
      Returns:
        A tuple consisting of:
        all_scores: A matrix (or list of matrices) of dimensions (num_input,
          num_clusters) where the value is the distance of an input vector and a
          cluster center.
        cluster_idx: A vector (or list of vectors). Each element in the vector
          corresponds to an input row in 'inp' and specifies the cluster id
          corresponding to the input.
        scores: Similar to cluster_idx but specifies the distance to the
          assigned cluster instead.
        training_op: an op that runs an iteration of training.
docstring_summary: Generate a training graph for kmeans algorithm.
docstring_tokens: Generate a training graph for kmeans algorithm .
function: def training_graph(self):
      """Generate a training graph for kmeans algorithm.
  
      Returns:
        A tuple consisting of:
        all_scores: A matrix (or list of matrices) of dimensions (num_input,
          num_clusters) where the value is the distance of an input vector and a
          cluster center.
        cluster_idx: A vector (or list of vectors). Each element in the vector
          corresponds to an input row in 'inp' and specifies the cluster id
          corresponding to the input.
        scores: Similar to cluster_idx but specifies the distance to the
          assigned cluster instead.
        training_op: an op that runs an iteration of training.
      """
      # Implementation of kmeans.
      inputs = self._inputs
      cluster_centers_var, total_counts = self._init_clusters()
      cluster_centers = cluster_centers_var
  
      if self._distance_metric == COSINE_DISTANCE:
        inputs = self._l2_normalize_data(inputs)
        if not self._clusters_l2_normalized():
          cluster_centers = tf.nn.l2_normalize(cluster_centers, dim=1)
  
      all_scores, scores, cluster_idx = self._infer_graph(inputs, cluster_centers)
      if self._use_mini_batch:
        training_op = self._mini_batch_training_op(
            inputs, cluster_idx, cluster_centers, cluster_centers_var,
            total_counts)
      else:
        assert cluster_centers == cluster_centers_var
        training_op = self._full_batch_training_op(inputs, cluster_idx,
                                                   cluster_centers_var)
      return all_scores, cluster_idx, scores, training_op
function_tokens: def training_graph ( self ) : # Implementation of kmeans. inputs = self . _inputs cluster_centers_var , total_counts = self . _init_clusters ( ) cluster_centers = cluster_centers_var if self . _distance_metric == COSINE_DISTANCE : inputs = self . _l2_normalize_data ( inputs ) if not self . _clusters_l2_normalized ( ) : cluster_centers = tf . nn . l2_normalize ( cluster_centers , dim = 1 ) all_scores , scores , cluster_idx = self . _infer_graph ( inputs , cluster_centers ) if self . _use_mini_batch : training_op = self . _mini_batch_training_op ( inputs , cluster_idx , cluster_centers , cluster_centers_var , total_counts ) else : assert cluster_centers == cluster_centers_var training_op = self . _full_batch_training_op ( inputs , cluster_idx , cluster_centers_var ) return all_scores , cluster_idx , scores , training_op