You would have to assign the new module to the attribute name e.g. via setattr. However, note that the resnet implementation reuses the nn.ReLU modules as seen in its definition so your approach won’t work.