Hello everyone,
I am building a modular framework for a series of tests. I was wondering if adding an optimizer instance to a nn.Module would cause any issues. Here is an example:
class EgModel(nn.Module):
   def __init__(self):
       self.net = nn.Sequential(...)
       self.optimizer = {‘optimizer_a’: optim.Adam(self.parameters())}
   
...

  def optimize(self, loss):
       self.optimizers['optimizer_a'].zero_grad()
       loss.backward()
       self.optimizers['optimizer_a'].step()

model = EgModel()
...
model.optimise(loss)

The code seems to be running but I am worried that certain things might not be working as they should under the hood.
The idea would be to add more optimizers in the context of a GAN.
Thank you for your time !