{"id":15132613,"url":"https://github.com/keon/deep-q-learning","last_synced_at":"2026-05-24T05:04:37.701Z","repository":{"id":44443702,"uuid":"81041977","full_name":"keon/deep-q-learning","owner":"keon","description":"Minimal Deep Q Learning (DQN \u0026 DDQN) implementations in Keras","archived":true,"fork":false,"pushed_at":"2020-12-04T22:57:25.000Z","size":1858,"stargazers_count":1293,"open_issues_count":18,"forks_count":453,"subscribers_count":64,"default_branch":"master","last_synced_at":"2025-01-18T22:38:52.597Z","etag":null,"topics":["ddqn","deep-learning","deep-q-network","deep-reinforcement-learning","dqn","reinforcement-learning"],"latest_commit_sha":null,"homepage":"https://keon.io/deep-q-learning","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-06T02:57:42.000Z","updated_at":"2025-01-17T02:47:43.000Z","dependencies_parsed_at":"2022-07-14T20:30:29.629Z","dependency_job_id":null,"html_url":"https://github.com/keon/deep-q-learning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/keon/deep-q-learning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keon%2Fdeep-q-learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keon%2Fdeep-q-learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keon%2Fdeep-q-learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keon%2Fdeep-q-learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keon","download_url":"https://codeload.github.com/keon/deep-q-learning/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keon%2Fdeep-q-learning/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277450939,"owners_count":25819971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddqn","deep-learning","deep-q-network","deep-reinforcement-learning","dqn","reinforcement-learning"],"created_at":"2024-09-26T04:21:44.756Z","updated_at":"2026-05-24T05:04:37.684Z","avatar_url":"https://github.com/keon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deep-q-learning\n\nIntroduction to Making a Simple Game AI with Deep Reinforcement Learning\n\n\n\n![animation](./assets/animation.gif)\n\nMinimal and Simple Deep Q Learning Implemenation in Keras and Gym. Under 100 lines of code!\n\nThe explanation for the `dqn.py` code is covered in the blog article\n[https://keon.kim/writing/deep-q-learning/](https://keon.kim/writing/deep-q-learning/)\n\n\nI made minor tweaks to this repository such as `load` and `save` functions for convenience.\n\nI also made the `memory` a deque instead of just a list.\nThis is in order to limit the maximum number of elements in the memory.\n\n\nThe training might be unstable for `dqn.py`. This problem is mitigated in `ddqn.py`.\nI'll cover `ddqn` in the next article.\n\n## Changelog\n\n### 2026-05\n- Migrated from `gym` to `gymnasium` and updated for the modern reset/step API.\n- Updated for Keras 3 (`Adam(learning_rate=)`, `Input` layer, `keras.losses.Huber`).\n- `ddqn.py` now implements actual Double DQN (online net selects, target net evaluates).\n- Removed CartPole-specific reward shaping from `ddqn.py` so it's env-agnostic.\n- `save()` / `load()` now persist `epsilon` alongside the weights.\n\n### 2018-08\n- Split batched-update training into its own file (`dqn_batch.py`).\n\n### 2017-06\n- Added Double DQN with Huber loss in `ddqn.py`.\n- Added `requirements.txt`.\n\n### 2017-05\n- Migrated to the Keras 2 API.\n- Hyperparameter tuning that finally got `dqn.py` learning reliably on CartPole.\n\n### 2017-02\n- Initial release: DQN agent on CartPole with experience replay (`deque`-bounded memory) and `save` / `load` helpers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeon%2Fdeep-q-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeon%2Fdeep-q-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeon%2Fdeep-q-learning/lists"}