Check out my tutorial, it covers this.

  
      
      GitHub
  
  
    

Spandan-Madan/A-Collection-of-important-tasks-in-pytorch 1.1k

A-Collection-of-important-tasks-in-pytorch - Everyday things people use in Pytorch. No need to spend hours reading Pytorch forums trying to find them!