Balance a pole on a moving cart with a Deep Q-Network trained from scratch in PyTorch. Explore CartPole's continuous state and a random baseline, build an experience-replay buffer, a small MLP Q-network with a periodically synced target network, an epsilon schedule and a Huber TD loss, then train under a hard step cap. Finish by plotting the learning curve, evaluating the greedy policy on seeded episodes and tracing the pole angle through a full rollout.
Environment Setup
Exploring CartPole
DQN Training
Evaluation
Premium Project
This guided, GPU-powered project is available to Premium members. Upgrade to train models end-to-end in an interactive notebook.