Main Content

cyclicalLearnRate

Cyclical learning rate schedule

Since R2024b

    Description

    A cyclical learning rate schedule periodically increases and decreases the learning rate.

    Tip

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

    Creation

    Description

    schedule = cyclicalLearnRate creates a cyclicalLearnRate object.

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

    example

    schedule = cyclicalLearnRate(Name=Value) specifies additional properties using one or more name-value arguments. For example, MaxFactor=2 specifies a maximum scaling factor of 2.

    example

    Properties

    expand all

    Maximum scaling factor, specified as a positive scalar.

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

    Number of steps in the cycle, specified as a positive integer.

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

    Ratio of time spent increasing versus decreasing the learning rate, specified as a scalar in the range (0,1).

    Data Types: single | double

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

    If FrequencyUnit is "epoch", then the software updates the learning rate every epoch and each iteration of the epoch uses the same learning rate. If FrequencyUnit is "iteration", then the software updates the learning rate every iteration.

    This property is read-only.

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

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

    Data Types: double

    Examples

    collapse all

    Create a cyclical learning rate schedule with the default settings.

    schedule = cyclicalLearnRate
    schedule = 
      cyclicalLearnRate with properties:
    
            MaxFactor: 5
               Period: 10
            StepRatio: 0.5000
        FrequencyUnit: "epoch"
             NumSteps: Inf
    
    

    Specify this schedule as a training option.

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

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

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

    Create a cyclical learning rate schedule that cycles for a period of 100 iterations.

    schedule = cyclicalLearnRate( ...
        Period=100, ...
        FrequencyUnit="iteration")
    schedule = 
      cyclicalLearnRate with properties:
    
            MaxFactor: 5
               Period: 100
            StepRatio: 0.5000
        FrequencyUnit: "iteration"
             NumSteps: Inf
    
    

    Specify this schedule as a training option.

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

    Algorithms

    expand all

    Version History

    Introduced in R2024b