Are arithmetic operations supported on `nn.Module` instances?

Hello,

Is there a native support in pytorch for arithmetic operations on nn.Modules objects? Say for example we want to compute the difference between two nn.Modules having the same architectures, currently I am looping over the parameters of the model and update them iteratively. I don’t think this is the optimal way to do it, since it requires running a for loop, which can be very slow on python. Does anyone have a better approach to do this?

1 Like

Check Stochastic Weight Averaging