Hi, I took your code and modified it a bit, but I think the thing that improved the most the duration of the episodes was changing the optimizer from Adam to RMSprop:
optimizer = optim.RMSprop(model.parameters())
“loss_fn = nn.SmoothL1Loss()”

20200329_2225_RMSpropOptimizer_SmothL1Loss_1000iterations1698×480 70.6 KB

and with Adam optimizer (“loss_fn = nn.SmoothL1Loss()” ):

20200329_2007_AdamOptimizer_SmothL1Loss_1000iterations1670×480 60.6 KB

The link to my code on GitHub:

  
      
      GitHub
  
  
    

DanielF29/Simple-CartPole-NN-using-PyTorch-and-OpenAI-Gym 25

Simple CartPole controled by a NN using PyTorch and OpenAI Gym - DanielF29/Simple-CartPole-NN-using-PyTorch-and-OpenAI-Gym