MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / OneCycleLR

Class OneCycleLR

optimizers/lr_scheduler.py:1089–1309  ·  view source on GitHub ↗

r"""Sets the learning rate of each parameter group according to the 1cycle learning rate policy. The 1cycle policy anneals the learning rate from an initial learning rate to some maximum learning rate and then from that maximum learning rate to some minimum learning rate much lower t

Source from the content-addressed store, hash-verified

1087
1088
1089class OneCycleLR(_LRScheduler):
1090 r"""Sets the learning rate of each parameter group according to the
1091 1cycle learning rate policy. The 1cycle policy anneals the learning
1092 rate from an initial learning rate to some maximum learning rate and then
1093 from that maximum learning rate to some minimum learning rate much lower
1094 than the initial learning rate.
1095 This policy was initially described in the paper `Super-Convergence:
1096 Very Fast Training of Neural Networks Using Large Learning Rates`_.
1097
1098 The 1cycle learning rate policy changes the learning rate after every batch.
1099 `step` should be called after a batch has been used for training.
1100
1101 This scheduler is not chainable.
1102
1103 Note also that the total number of steps in the cycle can be determined in one
1104 of two ways (listed in order of precedence):
1105
1106 #. A value for total_steps is explicitly provided.
1107 #. A number of epochs (epochs) and a number of steps per epoch
1108 (steps_per_epoch) are provided.
1109 In this case, the number of total steps is inferred by
1110 total_steps = epochs * steps_per_epoch
1111
1112 You must either provide a value for total_steps or provide a value for both
1113 epochs and steps_per_epoch.
1114
1115 Args:
1116 optimizer (Optimizer): Wrapped optimizer.
1117 max_lr (float or list): Upper learning rate boundaries in the cycle
1118 for each parameter group.
1119 total_steps (int): The total number of steps in the cycle. Note that
1120 if a value is not provided here, then it must be inferred by providing
1121 a value for epochs and steps_per_epoch.
1122 Default: None
1123 epochs (int): The number of epochs to train for. This is used along
1124 with steps_per_epoch in order to infer the total number of steps in the cycle
1125 if a value for total_steps is not provided.
1126 Default: None
1127 steps_per_epoch (int): The number of steps per epoch to train for. This is
1128 used along with epochs in order to infer the total number of steps in the
1129 cycle if a value for total_steps is not provided.
1130 Default: None
1131 pct_start (float): The percentage of the cycle (in number of steps) spent
1132 increasing the learning rate.
1133 Default: 0.3
1134 anneal_strategy (str): {'cos', 'linear'}
1135 Specifies the annealing strategy: "cos" for cosine annealing, "linear" for
1136 linear annealing.
1137 Default: 'cos'
1138 cycle_momentum (bool): If ``True``, momentum is cycled inversely
1139 to learning rate between 'base_momentum' and 'max_momentum'.
1140 Default: True
1141 base_momentum (float or list): Lower momentum boundaries in the cycle
1142 for each parameter group. Note that momentum is cycled inversely
1143 to learning rate; at the peak of a cycle, momentum is
1144 'base_momentum' and learning rate is 'max_lr'.
1145 Default: 0.85
1146 max_momentum (float or list): Upper momentum boundaries in the cycle

Callers 1

get_optimizer_schedulerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected