Main Content

piecewiseLearnRate

Piecewise learning rate schedule

Since R2024b

    Description

    A piecewise learning rate schedule object drops the learning rate periodically by multiplying it by a specified factor.

    Tip

    To easily use a piecewise learning rate schedule with the default options, specify the LearnRateSchedule argument of the trainingOptions function as "piecewise".

    Creation

    Description

    schedule = piecewiseLearnRate creates a piecewiseLearnRate object.

    This syntax is equivalent to setting the LearnRateSchedule argument of the trainingOptions function to "piecewise".

    example

    schedule = piecewiseLearnRate(Name=Value) specifies optional properties using one or more name-value arguments. For example, DropFactor=0.5 specifies halving the learning rate.

    example

    Properties

    expand all

    Scaling factor used to drop the learning rate, specified as a scalar in the range (0,1).

    If FrequencyUnit is "epoch", then the software updates the learning rate every Period epochs. If FrequencyUnit is "iteration", then the software updates the learning rate every Period iterations.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Number of steps before updating the learning rate, specified as a positive integer.

    If FrequencyUnit is "epoch", then the software updates the learning rate every Period epochs. If FrequencyUnit is "iteration", then the software updates the learning rate every Period iterations.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Frequency unit, specified as "epoch" or "iteration".

    If FrequencyUnit is "epoch", then the software updates the learning rate every Period epochs. If FrequencyUnit is "iteration", then the software updates the learning rate every Period iterations.

    This property is read-only.

    Number of steps to drop learning rate, specified as Inf.

    piecewiseLearnRate objects are infinite learning rate schedules, so NumSteps is Inf.

    Data Types: double

    Examples

    collapse all

    Create a piecewise learning rate schedule with the default settings.

    schedule = piecewiseLearnRate
    schedule = 
      piecewiseLearnRate with properties:
    
           DropFactor: 0.1000
               Period: 10
        FrequencyUnit: "epoch"
             NumSteps: Inf
    
    

    Specify this schedule as a training option.

    options = trainingOptions("adam",LearnRateSchedule=schedule);

    As an alternative to creating a piecewise learning rate schedule object, to easily use a piecewise learning rate schedule with the default options, specify the LearnRateSchedule argument of the trainingOptions function as "piecewise".

    options = trainingOptions("adam",LearnRateSchedule="piecewise");

    Create a piecewise learning rate schedule that halves the learning rate every 100 iterations.

    schedule = piecewiseLearnRate( ...
        DropFactor=0.5, ...
        Period=100, ...
        FrequencyUnit="iteration")
    schedule = 
      piecewiseLearnRate with properties:
    
           DropFactor: 0.5000
               Period: 100
        FrequencyUnit: "iteration"
             NumSteps: Inf
    
    

    Specify this schedule as a training option.

    options = trainingOptions("adam",LearnRateSchedule=schedule);

    Algorithms

    expand all

    Version History

    Introduced in R2024b