A simple PyTorch implementation of the Deep Q-Learning algorithm to solve Lunar Lander environment from Gymnasium.
AI Course Project - UniCT, DMI.
Replay Memory Capacity | Target-network sync-rate | Pre-trained models folder |
---|---|---|
500000 | 10 | link |
50000 | 10 | link |
5000 | 10 | link |
500000 | 1 | link |
500000 | 100 | link |
Download and install Anaconda
or miniconda
from the official website. Make it works by opening a shell and running:
$ conda env list
This should prompt the list of your conda environments. Now create a new environment:
$ conda create -n dqn python=3.9
And activate the new env:
$ conda activate dqn
Finally, clone the repository and install the aicourse
module running the following inside the project folder:
$ pip install -e .
Select one checkpoint from the models
folder, then use the play.py
script to let the agent play one episode:
(your_env) <Lunar-Lander-DQN> python play.py --help
usage: play.py [-h] [--model-ckpt MODEL_CKPT] [--episodes EPISODES]
optional arguments:
-h, --help show this help message and exit
--model-ckpt MODEL_CKPT
--episodes EPISODES
Example:
python play.py --model-ckpt models/ll-cap_500000_sr_10/models/ll-ep50.ckpt
Start the training using train.py
script:
(your_env) <Lunar-Lander-DQN> python train.py --help
usage: train.py [-h] [--dest DEST] [--epochs EPOCHS] [--episodes EPISODES] [--batch-size BATCH_SIZE] [--capacity CAPACITY]
[--sync-rate SYNC_RATE]
optional arguments:
-h, --help show this help message and exit
--dest DEST destination folder
--epochs EPOCHS number of epochs
--episodes EPISODES number of episodes to play in an epoch
--batch-size BATCH_SIZE batch size on trainin phase
--capacity CAPACITY capacity of the replay memory
--sync-rate SYNC_RATE sync rate of the target network