I am doing some transfer learning, and set a function inside my NN class as so:
    def freeze(self):    
        for name, child in self.arch.named_children():
            if name != "_fc":
                for param in child.parameters():
                    param.requires_grad = False
        for name, param in self.arch.named_parameters():
            if("bn" in name):
                param.requires_grad = True

Probably a bit convoluted I know, but I was basically just wanting to freeze everything except all BatchNorms and my classifier.
I instantiate my model like so:
   arch = EfficientNet.from_pretrained(param['arch'])   
    model = Net(arch=arch, n_meta_features=len(meta_features))  # New model for each fold 
    model.freeze()
    model = nn.DataParallel(model)
    model = model.to(device)

I think I must be doing something wrong however, because I would have suspected my optimizer to throw an error, as i was calling it like so:
    optim = torch.optim.AdamW(model.parameters(), lr=param['lr'], amsgrad=True) 

instead of like so:
    optim = torch.optim.AdamW(filter(lambda p: p.requires_grad, net.parameters()), lr=param['lr'], amsgrad=True) 


as it’s my understanding that the optimizer will throw an error if it encounters frozen parameters.  I also noticed that my training time (about 1min 47sec per epoch) is essentially unchanged as well, and I would have suspected it to train faster.
Is there something I am doing wrong?