parameters: (learning_rate,
                       decay_steps,
                       end_learning_rate=0.0001,
                       power=1.0,
                       cycle=False)
docstring: Applies polynomial decay to the initial learning rate.
  
      .. code-block:: text
  
       if cycle:
         decay_steps = decay_steps * ceil(global_step / decay_steps)
       else:
         global_step = min(global_step, decay_steps)
         decayed_learning_rate = (learning_rate - end_learning_rate) *
              (1 - global_step / decay_steps) ^ power + end_learning_rate
  
      Args:
          learning_rate(Variable|float32): A scalar float32 value or a Variable. This
            will be the initial learning rate during training.
          decay_steps(int32): A Python `int32` number.
          end_learning_rate(float): A Python `float` number.
          power(float): A Python `float` number.
          cycle(bool): If set true, decay the learning rate every decay_steps.
  
      Returns:
          Variable: The decayed learning rate
  
      Examples:
          .. code-block:: python
  
            import paddle.fluid as fluid
            start_lr = 0.01
            total_step = 5000
            end_lr = 0
            lr = fluid.layers.polynomial_decay(
                start_lr, total_step, end_lr, power=1)
docstring_summary: Applies polynomial decay to the initial learning rate.
docstring_tokens: Applies polynomial decay to the initial learning rate .
function: def polynomial_decay(learning_rate,
                       decay_steps,
                       end_learning_rate=0.0001,
                       power=1.0,
                       cycle=False):
      """
      Applies polynomial decay to the initial learning rate.
  
      .. code-block:: text
  
       if cycle:
         decay_steps = decay_steps * ceil(global_step / decay_steps)
       else:
         global_step = min(global_step, decay_steps)
         decayed_learning_rate = (learning_rate - end_learning_rate) *
              (1 - global_step / decay_steps) ^ power + end_learning_rate
  
      Args:
          learning_rate(Variable|float32): A scalar float32 value or a Variable. This
            will be the initial learning rate during training.
          decay_steps(int32): A Python `int32` number.
          end_learning_rate(float): A Python `float` number.
          power(float): A Python `float` number.
          cycle(bool): If set true, decay the learning rate every decay_steps.
  
      Returns:
          Variable: The decayed learning rate
  
      Examples:
          .. code-block:: python
  
            import paddle.fluid as fluid
            start_lr = 0.01
            total_step = 5000
            end_lr = 0
            lr = fluid.layers.polynomial_decay(
                start_lr, total_step, end_lr, power=1)
  
      """
      with default_main_program()._lr_schedule_guard():
          if in_dygraph_mode():
              decay = imperate_lr.PolynomialDecay(learning_rate, decay_steps,
                                                  end_learning_rate, power, cycle)
              return decay
          else:
              global_step = _decay_step_counter()
  
              if cycle:
                  div_res = ops.ceil(global_step / decay_steps)
                  zero_var = tensor.fill_constant(
                      shape=[1], dtype='float32', value=0.0)
                  one_var = tensor.fill_constant(
                      shape=[1], dtype='float32', value=1.0)
  
                  with control_flow.Switch() as switch:
                      with switch.case(global_step == zero_var):
                          tensor.assign(input=one_var, output=div_res)
                  decay_steps = decay_steps * div_res
              else:
                  decay_steps_var = tensor.fill_constant(
                      shape=[1], dtype='float32', value=float(decay_steps))
                  global_step = nn.elementwise_min(
                      x=global_step, y=decay_steps_var)
  
              decayed_lr = (learning_rate - end_learning_rate) * \
                  ((1 - global_step / decay_steps) ** power) + end_learning_rate
              return decayed_lr
function_tokens: def polynomial_decay ( learning_rate , decay_steps , end_learning_rate = 0.0001 , power = 1.0 , cycle = False ) : with default_main_program ( ) . _lr_schedule_guard ( ) : if in_dygraph_mode ( ) : decay = imperate_lr . PolynomialDecay ( learning_rate , decay_steps , end_learning_rate , power , cycle ) return decay else : global_step = _decay_step_counter ( ) if cycle : div_res = ops . ceil ( global_step / decay_steps ) zero_var = tensor . fill_constant ( shape = [ 1 ] , dtype = 'float32' , value = 0.0 ) one_var = tensor . fill_constant ( shape = [ 1 ] , dtype = 'float32' , value = 1.0 ) with control_flow . Switch ( ) as switch : with switch . case ( global_step == zero_var ) : tensor . assign ( input = one_var , output = div_res ) decay_steps = decay_steps * div_res else : decay_steps_var = tensor . fill_constant ( shape = [ 1 ] , dtype = 'float32' , value = float ( decay_steps ) ) global_step = nn . elementwise_min ( x = global_step , y = decay_steps_var ) decayed_lr = ( learning_rate - end_learning_rate ) * ( ( 1 - global_step / decay_steps ) ** power ) + end_learning_rate return decayed_lr