class_docstr: Define how to apply SVD algorithm.
  
  This periodic update and scheduling base SVD algorithm update the original
  weights to make lower rank by SVD for each update_freq steps. During the
  warmup steps, It adjust the rank from the original to target rank gradually.
class_docstr_tok: ["Define","how","to","apply","SVD","algorithm",".","This","periodic","update","and","scheduling","base","SVD","algorithm","update","the","original","weights","to","make","lower","rank","by","SVD","for","each","update_freq","steps",".","During","the","warmup","steps",",","It","adjust","the","rank","from","the","original","to","target","rank","gradually","."]
code: def compress_training_weights(
      self, weight: tf.Tensor, _
  ) -> List[tf.Tensor]:
      rank = self.rank
      s, u, v = tf.linalg.svd(weight)
  
      if len(weight.shape) == 2:
          # FC Layer
          s = s[:rank]
          u = u[:, :rank]
          v = v[:, :rank]
      elif len(weight.shape) == 4:
          # Conv2D Layer
          s = s[:, :, :rank]
          u = u[:, :, :, :rank]
          v = v[:, :, :, :rank]
      else:
          raise NotImplementedError(
              "Only for dimension=2 or 4 is supported."
          )
  
      sv = tf.matmul(tf.linalg.diag(s), v, adjoint_b=True)
  
      return [u, sv]
  
file_path: model-optimization/tensorflow_model_optimization/python/core/common/keras/compression/algorithms/periodical_update_and_scheduling.py
imports: from typing import List
  import tensorflow
  from tensorflow_model_optimization.python.core.common.keras.compression import algorithm
label_desc: Use image node_id 5 for calling the SVD obj's underlying member method code with example usage: obj.compress_training_weights(weight, _) and returns: list