{"id":24475433,"url":"https://github.com/jenson073/reinforment-learning_cartpole","last_synced_at":"2026-05-17T20:33:20.895Z","repository":{"id":260923726,"uuid":"882727448","full_name":"Jenson073/Reinforment-learning_cartpole","owner":"Jenson073","description":"This project serves as an introduction to Deep Q-Learning and reinforcement learning concepts. The trained agent learns to balance the cart-pole system through iterative training and evaluation. You can modify the environment or parameters to further experiment with different reinforcement learning strategies.","archived":false,"fork":false,"pushed_at":"2024-12-22T18:45:38.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-01T23:29:53.670Z","etag":null,"topics":["cart-pole","q-learning-algorithm","reinforcement-learning"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jenson073.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-11-03T15:52:23.000Z","updated_at":"2024-12-22T19:03:42.000Z","dependencies_parsed_at":"2025-03-15T04:15:50.154Z","dependency_job_id":null,"html_url":"https://github.com/Jenson073/Reinforment-learning_cartpole","commit_stats":null,"previous_names":["jenson073/repository2"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Jenson073/Reinforment-learning_cartpole","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jenson073%2FReinforment-learning_cartpole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jenson073%2FReinforment-learning_cartpole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jenson073%2FReinforment-learning_cartpole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jenson073%2FReinforment-learning_cartpole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jenson073","download_url":"https://codeload.github.com/Jenson073/Reinforment-learning_cartpole/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jenson073%2FReinforment-learning_cartpole/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33153800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cart-pole","q-learning-algorithm","reinforcement-learning"],"created_at":"2025-01-21T09:14:51.153Z","updated_at":"2026-05-17T20:33:20.865Z","avatar_url":"https://github.com/Jenson073.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 **Reinforcement Learning with Deep Q-Network (DQN)**  \n\nThis project demonstrates the implementation of a **Deep Q-Network (DQN)** to solve the classic control problem **CartPole-v1** (or **MountainCar-v0**) using the OpenAI Gym environment. The DQN agent learns optimal policies through experience replay and an epsilon-greedy strategy.  \n\n---\n\n## 🌟 **Project Overview**  \n\n### **Environment**  \n- **CartPole-v1**: A pole is attached to a cart, which moves along a frictionless track. The agent balances the pole by applying forces left or right.  \n- **State Size**: `4` (position, velocity, angle, angular velocity).  \n- **Action Size**: `2` (left or right).  \n\nAlternatively, the code can be used for **MountainCar-v0**: The goal is to drive a car up a steep hill.  \n\n---\n\n## 🧠 **Deep Q-Network (DQN)**  \n\n- **Model Architecture**:  \n  - Input: State size (4).  \n  - Two hidden layers with 24 neurons each and **ReLU** activation.  \n  - Output: Action size (2) with **linear** activation for Q-values.  \n  - Optimizer: **Adam** with learning rate `0.001`.  \n  - Loss Function: **Mean Squared Error (MSE)**.  \n\n- **Training Mechanism**:  \n  - Experience replay: Stores past experiences in a replay memory buffer to break the correlation in sequential data.  \n  - Target Q-Value:  \n    \\[\n    Q_{\\text{target}} = \\text{reward} + \\gamma \\cdot \\max(Q(\\text{next state}))\n    \\]\n  - Epsilon-greedy exploration: Balances exploration and exploitation with a decaying epsilon.  \n\n---\n\n## ⚙️ **Parameters**  \n\n| Parameter           | Value              | Description                              |\n|---------------------|--------------------|------------------------------------------|\n| Episodes            | 20                | Number of episodes to train.            |\n| Max Steps           | 100               | Maximum steps per episode.              |\n| Learning Rate       | 0.001             | Learning rate for the optimizer.        |\n| Discount Factor (γ) | 0.95              | Discount factor for future rewards.     |\n| Epsilon             | 1.0 (decays)      | Initial exploration rate.               |\n| Epsilon Decay       | 0.995             | Decay rate for epsilon.                 |\n| Epsilon Min         | 0.01              | Minimum exploration rate.               |\n| Batch Size          | 64                | Size of minibatch for training.         |\n| Memory Size         | 2000              | Maximum size of replay memory.          |\n\n---\n\n## 📊 **Results**  \n\n- The agent trains for 20 episodes, accumulating rewards over time.  \n- Intermediate scores are printed every 10 steps for transparency.  \n- A plot of scores over episodes visualizes the training progress.\n\n---\n\n## 🔧 **How to Run the Code**  \n\n1. **Install Dependencies**:  \n   Ensure you have Python installed along with the required libraries:  \n   ```bash\n   pip install gym tensorflow matplotlib numpy\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenson073%2Freinforment-learning_cartpole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenson073%2Freinforment-learning_cartpole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenson073%2Freinforment-learning_cartpole/lists"}