All Parameters of Models

Hi everyone,

I have a question that how to optimize all parameters if model A includes model B?
For example,
class Model_B:
def init():

class Model_A:
def init():
self.b = Model_B()

And then (in

a = Model_A()
optim.SGD(a.parameters(), lr=0.001, momentum=0.9) # Does it optimize the parameters of Model A and Model B??


If model B is a class that inherits from the nn.Module it should also be included in the a.parameters() call. So yes, it should work :slight_smile:

Try printing the a.parameters() to see if you can spot the model B parameters just to confirm