Objects of the same class

Hi all,

I have a basic Pytorch question!
If I create three objects of one torch.nn.Module class, do they share the same parameters i.e. those parameters influence each other or I’ll have three distinct sets of totally separated parameters?

For example, let’s say my class is an autoencoder, I’ll create three objects of it, feed different inputs to these objects and train those three autoencoder objects with their own optimizers. Is there any connection between parameters of these three objects?

Thanks!

They do not share the same parameters. For example, consider nn.Linear(). Each time when we create an object, they have their own weights.

There would not be any connection unless you share some modules. ( for example, by passing through constructor)

1 Like