Loading weights for specific layer from .pt file

I would like to monitor the change of weights in every epoch.

So i use torch.save.
torch.save({‘epoch’: epoch,
‘net_state_dict’: net.state_dict(),
‘optimizer_state_dict’: optimizer.state_dict()},

Then, i train ResNet-34 for CIFAR-10 image classification.

If the above function is used, a large amount of tensors are recorded, making it difficult to measure.
So, I want to monitor the weight of a specific layer or measure the mean of a specific tensor.

Any advice would be appreciated!

In case you want to print some stats of a specific parameter you could access it directly via model.layer.weight and compute the stats of it. Would this work or what exactly are you looking for?

1 Like

Thanks!! Yes that’s what i’m looking for!