original_docstring: 
      Applies cosine decay to generate learning rate array.
  
      Args:
         steps_per_epoch(int): steps number per epoch
         total_epochs(int): all epoch in training.
         lr_init(float): init learning rate.
         lr_end(float): end learning rate
         lr_max(float): max learning rate.
         warmup_steps(int): all steps in warmup epochs.
  
      Returns:
         np.array, learning rate array.
      
docstring: Applies cosine decay to generate learning rate array.
docstring_tokens: Applies cosine decay to generate learning rate array .
code: def generate_cosine_lr(steps_per_epoch, total_epochs,
                         lr_init=config.lr_init,
                         lr_end=config.lr_end,
                         lr_max=config.lr_max,
                         warmup_epochs=config.warmup_epochs):
      """
      Applies cosine decay to generate learning rate array.
  
      Args:
         steps_per_epoch(int): steps number per epoch
         total_epochs(int): all epoch in training.
         lr_init(float): init learning rate.
         lr_end(float): end learning rate
         lr_max(float): max learning rate.
         warmup_steps(int): all steps in warmup epochs.
  
      Returns:
         np.array, learning rate array.
      """
      total_steps = steps_per_epoch * total_epochs
      warmup_steps = steps_per_epoch * warmup_epochs
      decay_steps = total_steps - warmup_steps
      lr_each_step = []
      for i in range(total_steps):
          if i < warmup_steps:
              lr_inc = (float(lr_max) - float(lr_init)) / float(warmup_steps)
              lr = float(lr_init) + lr_inc * (i + 1)
          else:
              cosine_decay = 0.5 * (1 + math.cos(math.pi * (i - warmup_steps) / decay_steps))
              lr = (lr_max - lr_end) * cosine_decay + lr_end
          lr_each_step.append(lr)
      learning_rate = np.array(lr_each_step).astype(np.float32)
      current_step = steps_per_epoch * (config.start_epoch - 1)
      learning_rate = learning_rate[current_step:]
      return learning_rate
code_tokens: def generate_cosine_lr ( steps_per_epoch , total_epochs , lr_init = config . lr_init , lr_end = config . lr_end , lr_max = config . lr_max , warmup_epochs = config . warmup_epochs ) : total_steps = steps_per_epoch * total_epochs warmup_steps = steps_per_epoch * warmup_epochs decay_steps = total_steps - warmup_steps lr_each_step = [ ] for i in range ( total_steps ) : if i < warmup_steps : lr_inc = ( float ( lr_max ) - float ( lr_init ) ) / float ( warmup_steps ) lr = float ( lr_init ) + lr_inc * ( i + 1 ) else : cosine_decay = 0.5 * ( 1 + math . cos ( math . pi * ( i - warmup_steps ) / decay_steps ) ) lr = ( lr_max - lr_end ) * cosine_decay + lr_end lr_each_step . append ( lr ) learning_rate = np . array ( lr_each_step ) . astype ( np . float32 ) current_step = steps_per_epoch * ( config . start_epoch - 1 ) learning_rate = learning_rate [ current_step : ] return learning_rate
short_docstring: Applies cosine decay to generate learning rate array.
short_docstring_tokens: Applies cosine decay to generate learning rate array .
comment: """
      Applies cosine decay to generate learning rate array.
  
      Args:
         steps_per_epoch(int): steps number per epoch
         total_epochs(int): all epoch in training.
         lr_init(float): init learning rate.
         lr_end(float): end learning rate
         lr_max(float): max learning rate.
         warmup_steps(int): all steps in warmup epochs.
  
      Returns:
         np.array, learning rate array.
      """