Adaptive Pooling in PyTorch
Tips and Traps¶
- Adpative pooling an generate fixed-sized output, which enables a model to handle varying sized input. The models in torchvision are such examples.
References¶
Ways to Enable and Disable Gradient in PyTorch
set_grad_enable¶
Make Your Model Training Reproducible in PyTorch
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
The PyTorch doc Reproducibility has very detailed instructions on how to make your model training reproducible. Basically, you need the following code.
torch.manual_seed(args.seed)
np.random.seed(args.seed …
Delete a Layer in a Pretrained Model in PyTorch
It is common to customize a pretrained model by delete the output layer or replace it to the output layer that suits your use case. There are several ways to achieve this in PyTorch.
Replace the Fully Connected Layer with an Identity Layer¶
Define an identity layer.
Replace the fully connected layer with an Identity Layer (using ResNet18 as an example).