mindspore.DynamicLossScaleManager

class mindspore.DynamicLossScaleManager(init_loss_scale=2 ** 24, scale_factor=2, scale_window=2000)[source]

Loss scale that dynamically adjusts itself, inherits from LossScaleManager.

Parameters
  • init_loss_scale (float) – Initialize loss scale. Default: 2**24.

  • scale_factor (int) – Coefficient of increase and decrease. Default: 2.

  • scale_window (int) – Maximum continuous normal steps when there is no overflow. Default: 2000.

Examples

>>> from mindspore import Model, nn, DynamicLossScaleManager
>>>
>>> net = Net()
>>> loss_scale_manager = DynamicLossScaleManager()
>>> optim = nn.Momentum(params=net.trainable_params(), learning_rate=0.1, momentum=0.9)
>>> model = Model(net, loss_scale_manager=loss_scale_manager, optimizer=optim)
get_drop_overflow_update()[source]

Get the flag whether to drop optimizer update when there is an overflow.

Returns

bool, always return True at DynamicLossScaleManager.

get_loss_scale()[source]

Get loss scale value.

Returns

bool, loss_scale value.

get_update_cell()[source]

Returns the update cell for TrainOneStepWithLossScaleCell.

Returns

Cell, cell object used to update loss_scale.

update_loss_scale(overflow)[source]

Update loss scale value.

Parameters

overflow (bool) – Whether it overflows.