Remove RELU activation from Resnet model in Pytorch
How to remove all RELU activation layers from Resnet model in pytorch and if possible replace it by a linear activation layer?

model = models.resnet50()

names = []
for name, module in model.named_modules():
    if hasattr(module, 'relu'):
        module.relu = nn.Sigmoid() // or nn.Identity() accordingly

print(model)


This works for either replacing activations or making it identity
