{"id":24676183,"url":"https://github.com/konyd/deepqlearning-cartpole","last_synced_at":"2026-04-12T00:47:30.664Z","repository":{"id":274287796,"uuid":"922468053","full_name":"KonyD/DeepQLearning-CartPole","owner":"KonyD","description":"This repository implements a Deep Q-Learning algorithm to train an agent to balance a pole on a cart using the CartPole-v1 environment from Gymnasium. The project includes a TensorFlow-based neural network, epsilon-greedy exploration, experience replay, and visualization of the trained agent's performance.","archived":false,"fork":false,"pushed_at":"2025-01-26T09:52:57.000Z","size":0,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T10:28:18.270Z","etag":null,"topics":["deep-learning","deepq-learning","gymnasium","keras","python","tensorflow"],"latest_commit_sha":null,"homepage":"","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/KonyD.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-26T09:46:33.000Z","updated_at":"2025-01-26T09:54:17.000Z","dependencies_parsed_at":"2025-01-26T10:38:24.048Z","dependency_job_id":null,"html_url":"https://github.com/KonyD/DeepQLearning-CartPole","commit_stats":null,"previous_names":["konyd/deepqlearning-cartpole"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KonyD%2FDeepQLearning-CartPole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KonyD%2FDeepQLearning-CartPole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KonyD%2FDeepQLearning-CartPole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KonyD%2FDeepQLearning-CartPole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KonyD","download_url":"https://codeload.github.com/KonyD/DeepQLearning-CartPole/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244831290,"owners_count":20517663,"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","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":["deep-learning","deepq-learning","gymnasium","keras","python","tensorflow"],"created_at":"2025-01-26T12:14:16.167Z","updated_at":"2026-04-12T00:47:30.617Z","avatar_url":"https://github.com/KonyD.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deep Q-Learning with CartPole\n\nThis project implements a Deep Q-Learning (DQL) agent to solve the CartPole-v1 environment using the Gymnasium library. The agent leverages a neural network to learn the optimal policy for balancing the pole on the cart.\n\n## Features\n\n- **Environment:** The project uses the CartPole-v1 environment from Gymnasium.\n- **Neural Network:** A fully connected feedforward neural network is implemented using TensorFlow/Keras.\n- **Replay Memory:** The agent uses experience replay to train on past experiences.\n- **Epsilon-Greedy Strategy:** Balances exploration and exploitation during training.\n- **Training and Testing Modes:** The trained model is tested to demonstrate its performance.\n\n## Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/KonyD/DeepQLearning-CartPole.git\n   cd DeepQLearning-CartPole \n   ```\n\n2. Install the required dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n## File Structure\n\n- `main.py`: The main script containing the implementation of the DQL agent and training/testing logic.\n- `requirements.txt`: List of dependencies for the project.\n- `README.md`: Project documentation.\n\n## Usage\n\n1. **Train the Agent:**\n   Run the script to train the agent:\n   ```bash\n   python main.py\n   ```\n\n   The agent will train for a specified number of episodes and log its performance.\n\n2. **Test the Trained Model:**\n   The script includes a testing phase where the trained model is evaluated in the CartPole environment.\n\n## Key Parameters\n\n- `gamma`: Discount factor for future rewards (default: `0.95`).\n- `epsilon`: Initial exploration rate (default: `1`).\n- `epsilon_decay`: Decay rate for exploration (default: `0.995`).\n- `epsilon_min`: Minimum exploration rate (default: `0.01`).\n- `batch_size`: Size of the minibatch used for training (default: `32`).\n- `episodes`: Number of training episodes (default: `50`).\n\n## Dependencies\n\n- Python 3.8+\n- Gymnasium\n- TensorFlow/Keras\n- NumPy\n- tqdm\n\nYou can install the required libraries using the following command:\n```bash\npip install -r requirements.txt\n```\n\n## Results\n\nThe agent is trained to balance the pole for as long as possible. During training, the epsilon-greedy strategy ensures the agent explores the environment initially and focuses on exploitation as training progresses.\n\n## Acknowledgments\n\n- [OpenAI Gymnasium](https://gymnasium.farama.org/) for providing the CartPole-v1 environment.\n- [TensorFlow](https://www.tensorflow.org/) for neural network implementation.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonyd%2Fdeepqlearning-cartpole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonyd%2Fdeepqlearning-cartpole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonyd%2Fdeepqlearning-cartpole/lists"}