swfearp commented on issue #17881: Solved Bug: contrib/amp/loss_scalar.py not 
initializing variables
URL: 
https://github.com/apache/incubator-mxnet/issues/17881#issuecomment-607702769
 
 
   Hey, here are the amp lines:
   
   ```
   amp.init()
   ```
   
   ...
   optimizer = mx.optimizer.SGD(learning_rate=self.lr, momentum=self.momentum, 
wd=self.wd)
   trainer = gluon.Trainer(params=self.model.collect_params(), 
optimizer=optimizer)
   amp.init_trainer(trainer)
   ```
   
   ```
   with autograd.record():
        outputs = [self.model(X) for X in data]
        losses = [loss_function(output, label) for output, label in 
zip(outputs, smooth_labels)]
   
        with amp.scale_loss(losses, trainer) as scaled_loss:
             autograd.backward(scaled_loss)
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to