I tried to use Resnet50 to extract images’ feature and classify it by our own CNNNet.

I want to know whether totch.no_grad() makes optimizer.step() invalid during updating parameters of Resnet50.
If yes, how could I change it, because pycharm warns out of memory without torch.no_grad .