kice opened a new issue #9689: How to use gluon to train GAN network on 
multiple GPUs?
URL: https://github.com/apache/incubator-mxnet/issues/9689
 
 
   I come up with a solution, but it trains discriminator for an epoch and then 
uses the same thing to train the generator.
   ```
   def forward_backward(net, data, label):
       with autograd.record():
           losses_D = [loss(netD(X), Y) for X, Y in zip(data, label)]
       for l in losses_D:
           l.backward()
   
       with autograd.record():
           losses_G = [loss(netG(X), Y) for X, Y in zip(data, label)]
       for l in losses_G:
           l.backward()
   
   label = gluon.utils.split_and_load(trainging_data, ctx)
   forward_backward(net, data, label)
   ```
   I want to update the both network by batch.  Something like:
   ```
   def forward_backward(net, data, label):
       for X, Y in zip(data, label)
           with autograd.record():
               losses_D.append(loss(netD(X), Y))
   
           for l in losses_D:
               l.backward()
   
           with autograd.record():
               losses_G.append(loss(netG(X), Y))
   
           for l in losses_G:
               l.backward()
   
   label = gluon.utils.split_and_load(trainging_data, ctx)
   forward_backward(net, data, label)
   ```
   
   I have no idea if this code will work. Please let me know if it works.

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


With regards,
Apache Git Services

Reply via email to