It would be helpful to take a look on the code there you collect the features from resnet. “backward through resnet” means: if you collect your features then resnet in training mode and do it without with torch.no_grad context your matrix will be connected to resnet computational graph.