Single-file PyTorch DQN example with training and evaluation on CartPole.
-
Install dependencies:
- pip install torch gymnasium numpy
-
Train and evaluate:
- python "Neural Network by Pytorch.py"
- Trains for 300 episodes by default.
- Saves model to dqn_cartpole.pt.
- Prints a final summary with rewards, loss, and eval score.