Paper-Reading

Pytorch

tags: Pytorch

How to finetune a network

  1. Modify dataLoader / Class for custom dataset
  2. segmentation tasks 1. modify the palette for rendering the result labels
  3. modify num_classes
  4. dataloader part: modify __init__ and __getitem__
  5. Modify training code:
  6. Change dataset. - import new dataset functions and classes - change initialization for the dataset - change mean-std - modify all parts associated with dataset: eg. xxxDataset.num_class
  7. Net Surgery - Load initial net - modify
    • net_init.final._modules['4'] = nn.Conv2d(512, UAVDataset.num_classes, kernel_size=1).cuda()
  8. Hook https://pytorch.org/tutorials/beginner/former_torchies/nn_tutorial.html#forward-and-backward-function-hooks
  9. Extract Features: https://becominghuman.ai/extract-a-feature-vector-for-any-image-with-pytorch-9717561d1d4c