Haris Colic commited on
Commit
97c6dc9
Β·
verified Β·
1 Parent(s): dd732f1

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. .gitattributes +2 -0
  2. README.md +118 -0
  3. episodes.csv +0 -0
  4. losses.csv +0 -0
  5. result-50M-frames.gif +3 -0
  6. training-curves.png +3 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ result-50M-frames.gif filter=lfs diff=lfs merge=lfs -text
37
+ training-curves.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - reinforcement-learning
5
+ - dqn
6
+ - deep-q-learning
7
+ - atari
8
+ - ale
9
+ - space-invaders
10
+ - pytorch
11
+ library_name: pytorch
12
+ pipeline_tag: reinforcement-learning
13
+ ---
14
+
15
+ # DQN β€” ALE/SpaceInvaders-v5
16
+
17
+ <p align="center">
18
+ <img src="./result-50M-frames.gif" alt="Trained agent playing Space Invaders"/>
19
+ </p>
20
+
21
+ A from-scratch PyTorch reimplementation of DeepMind's DQN Atari papers ([Mnih et al.,
22
+ 2013](https://arxiv.org/pdf/1312.5602.pdf), [Mnih et al.,
23
+ 2015](https://www.nature.com/articles/nature14236/)), trained on `ALE/SpaceInvaders-v5`.
24
+
25
+ - **Code / training pipeline:** https://github.com/colichar/deep-q-learning
26
+ - **Architecture:** DeepMind's original conv/FC Q-network (3 conv layers + 2 FC layers), operating on stacks of 4
27
+ grayscale 84x84 frames.
28
+ - **Framework:** PyTorch.
29
+
30
+ ## Training setup
31
+
32
+ Trained for 50M frames (~12.5 hours) on a single RTX 4070 Ti Super, with a single `gymnasium` environment
33
+ (`num_envs=1`). Hyperparameters match the DeepMind 2015 paper, with a centered RMSprop optimizer:
34
+
35
+ | Hyperparameter | Value |
36
+ | --- | --- |
37
+ | Optimizer | RMSprop (centered, `alpha=0.95`, `eps=0.01`) |
38
+ | Learning rate | 0.00025 |
39
+ | Discount (gamma) | 0.99 |
40
+ | Replay memory size | 1,000,000 frames |
41
+ | Memory warmup | 50,000 frames |
42
+ | Batch size | 32 |
43
+ | Target network sync | every 10,000 frames |
44
+ | Main network update | every 4 frames |
45
+ | Frame skip | 4 (with max-pooling over the last 2 frames for flicker removal) |
46
+ | Reward clipping | {-1, 0, 1} |
47
+
48
+ See the [repo README](https://github.com/colichar/deep-q-learning#start-training) for the full flag list.
49
+
50
+ ## Results
51
+
52
+ Over the last 1M frames of training (501 episodes): **average episode reward β‰ˆ 1968.6**, max episode reward 4155.
53
+
54
+ <p align="center">
55
+ <img src="./training-curves.png" alt="Episode reward and training loss over 50M frames"/>
56
+ </p>
57
+
58
+ Reward is the 200-episode rolling mean (shaded band: raw per-episode reward); loss is the Huber loss averaged
59
+ every 400 frames, on a log scale.
60
+
61
+ ## Files
62
+
63
+ - `model.pth` β€” `torch.save` dict with `model_state_dict` and `optimizer_state_dict` for the main Q-network.
64
+ - `episodes.csv` β€” per-episode `frame_num,episode_num,episode_reward,epsilon,wall_clock_elapsed_seconds`, full
65
+ training run.
66
+ - `losses.csv` β€” `frame_num,avg_loss`, Huber loss averaged every 400 frames.
67
+ - `training-curves.png` β€” the plot above, generated from the two CSVs.
68
+
69
+ The replay memory buffer (~14GB) used to resume training locally is intentionally **not** included here β€” it's
70
+ only needed to resume training, not to run or evaluate the model.
71
+
72
+ ## Usage
73
+
74
+ The checkpoint's state dict matches `src.models.cnn_model_py.CNNModelPY` in the linked repo and is loaded through
75
+ `SpaceInvaderAgent`, not standalone `torch.load` + a bare `nn.Module` β€” see
76
+ [`scripts/evaluate.py`](https://github.com/colichar/deep-q-learning/blob/main/scripts/evaluate.py):
77
+
78
+ ```bash
79
+ git clone https://github.com/colichar/deep-q-learning
80
+ cd deep-q-learning
81
+ uv sync --extra cpu # or --extra cuda
82
+ uv run AutoROM --accept-license -y
83
+
84
+ # download this checkpoint's model/ dir from the Hub into, e.g., checkpoint/model/
85
+ uv run python scripts/evaluate.py --checkpoint checkpoint --optimizer rmsprop --episodes 5
86
+ ```
87
+
88
+ ## Limitations
89
+
90
+ - Trained and evaluated on a single game (`ALE/SpaceInvaders-v5`); the network is not general-purpose across
91
+ Atari games without retraining.
92
+ - Intended for research/education (reproducing the DQN papers), not as a production game-playing agent.
93
+
94
+ ## License
95
+
96
+ MIT β€” see [LICENSE](https://github.com/colichar/deep-q-learning/blob/main/LICENSE) in the linked repo.
97
+
98
+ ## Citation
99
+
100
+ ```bibtex
101
+ @article{mnih2013playing,
102
+ title={Playing atari with deep reinforcement learning},
103
+ author={Mnih, Volodymyr and Kavukcuoglu, Koray and Silver, David and Graves, Alex and Antonoglou, Ioannis and Wierstra, Daan and Riedmiller, Martin},
104
+ journal={arXiv preprint arXiv:1312.5602},
105
+ year={2013}
106
+ }
107
+
108
+ @article{mnih2015human,
109
+ title={Human-level control through deep reinforcement learning},
110
+ author={Mnih, Volodymyr and Kavukcuoglu, Koray and Silver, David and Rusu, Andrei A and Veness, Joel and Bellemare, Marc G and Graves, Alex and Riedmiller, Martin and Fidjeland, Andreas K and Ostrovski, Georg and others},
111
+ journal={Nature},
112
+ volume={518},
113
+ number={7540},
114
+ pages={529--533},
115
+ year={2015},
116
+ publisher={Nature Publishing Group}
117
+ }
118
+ ```
episodes.csv ADDED
The diff for this file is too large to render. See raw diff
 
losses.csv ADDED
The diff for this file is too large to render. See raw diff
 
result-50M-frames.gif ADDED

Git LFS Details

  • SHA256: 5cb34163ac83ad05430f3c28386876daf1d2885f7904bc5628a563acd3f489ca
  • Pointer size: 132 Bytes
  • Size of remote file: 2.31 MB
training-curves.png ADDED

Git LFS Details

  • SHA256: f27f147ed76dccf445af11425ea2b1f7f671f1e2a85100b5557c1fe73803666f
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB