bniladridas commited on
Commit ·
e93dd02
1
Parent(s): d4a0976
Update README: remove broken links, update username to harpertoken, simplify model name to CartPole, remove noise from inference code
Browse files
README.md
CHANGED
|
@@ -12,7 +12,7 @@ datasets:
|
|
| 12 |
metrics:
|
| 13 |
- mean_episode_length
|
| 14 |
model-index:
|
| 15 |
-
- name: CartPole
|
| 16 |
results:
|
| 17 |
- task:
|
| 18 |
type: optimization
|
|
@@ -28,19 +28,9 @@ license: mit
|
|
| 28 |
pipeline_tag: reinforcement-learning
|
| 29 |
---
|
| 30 |
|
| 31 |
-
# CartPole
|
| 32 |
-
|
| 33 |
-
This model provides a solution to the CartPole-v1 environment using CMA-ES (Covariance Matrix Adaptation Evolution Strategy),
|
| 34 |
-
achieving perfect performance with a simple linear policy. The implementation demonstrates how evolutionary strategies can
|
| 35 |
-
effectively solve classic control problems with minimal architecture complexity.
|
| 36 |
-
|
| 37 |
-
### Video Preview
|
| 38 |
-
|
| 39 |
-
<video controls width="480">
|
| 40 |
-
<source src="https://huggingface.co/bniladridas/cartpole-cmaes/resolve/main/preview.mp4" type="video/mp4">
|
| 41 |
-
Your browser does not support the video tag.
|
| 42 |
-
</video>
|
| 43 |
|
|
|
|
| 44 |
|
| 45 |
### Training Convergence
|
| 46 |

|
|
@@ -60,7 +50,6 @@ This is a linear policy model for the CartPole-v1 environment that:
|
|
| 60 |
def get_action(self, observation):
|
| 61 |
observation = np.array(observation, dtype=np.float32)
|
| 62 |
action_scores = np.dot(observation, self.weights)
|
| 63 |
-
action_scores += np.random.randn(*action_scores.shape) * 1e-5
|
| 64 |
return int(np.argmax(action_scores))
|
| 65 |
```
|
| 66 |
|
|
@@ -72,9 +61,9 @@ def get_action(self, observation):
|
|
| 72 |
|
| 73 |
### Model Sources
|
| 74 |
|
| 75 |
-
- **
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
| 79 |
## Uses
|
| 80 |
|
|
@@ -126,7 +115,7 @@ Users should:
|
|
| 126 |
from model import CMAESAgent
|
| 127 |
|
| 128 |
# Load the model
|
| 129 |
-
agent = CMAESAgent.from_pretrained("
|
| 130 |
|
| 131 |
# Evaluate
|
| 132 |
mean_reward, std_reward = agent.evaluate(num_episodes=5)
|
|
@@ -219,7 +208,6 @@ class CMAESAgent:
|
|
| 219 |
def get_action(self, observation):
|
| 220 |
observation = np.array(observation, dtype=np.float32)
|
| 221 |
action_scores = np.dot(observation, self.weights)
|
| 222 |
-
action_scores += np.random.randn(*action_scores.shape) * 1e-5 # Small noise for stability
|
| 223 |
return int(np.argmax(action_scores))
|
| 224 |
```
|
| 225 |
|
|
@@ -236,12 +224,11 @@ The model's simplicity demonstrates that CartPole's optimal control policy is ap
|
|
| 236 |
|
| 237 |
**BibTeX:**
|
| 238 |
```bibtex
|
| 239 |
-
@misc{
|
| 240 |
author = {Niladri Das},
|
| 241 |
-
title = {CartPole
|
| 242 |
year = {2025},
|
| 243 |
publisher = {Hugging Face},
|
| 244 |
journal = {Hugging Face Model Hub},
|
| 245 |
-
howpublished = {https://huggingface.co/
|
| 246 |
-
url = {https://github.com/bniladridas/cmaes-rl}
|
| 247 |
}
|
|
|
|
| 12 |
metrics:
|
| 13 |
- mean_episode_length
|
| 14 |
model-index:
|
| 15 |
+
- name: CartPole
|
| 16 |
results:
|
| 17 |
- task:
|
| 18 |
type: optimization
|
|
|
|
| 28 |
pipeline_tag: reinforcement-learning
|
| 29 |
---
|
| 30 |
|
| 31 |
+
# CartPole Solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
This model solves CartPole-v1 using CMA-ES with a linear policy.
|
| 34 |
|
| 35 |
### Training Convergence
|
| 36 |

|
|
|
|
| 50 |
def get_action(self, observation):
|
| 51 |
observation = np.array(observation, dtype=np.float32)
|
| 52 |
action_scores = np.dot(observation, self.weights)
|
|
|
|
| 53 |
return int(np.argmax(action_scores))
|
| 54 |
```
|
| 55 |
|
|
|
|
| 61 |
|
| 62 |
### Model Sources
|
| 63 |
|
| 64 |
+
- **Hugging Face:** https://huggingface.co/harpertoken/cartpole-cmaes
|
| 65 |
+
|
| 66 |
+
|
| 67 |
|
| 68 |
## Uses
|
| 69 |
|
|
|
|
| 115 |
from model import CMAESAgent
|
| 116 |
|
| 117 |
# Load the model
|
| 118 |
+
agent = CMAESAgent.from_pretrained("harpertoken/cartpole-cmaes")
|
| 119 |
|
| 120 |
# Evaluate
|
| 121 |
mean_reward, std_reward = agent.evaluate(num_episodes=5)
|
|
|
|
| 208 |
def get_action(self, observation):
|
| 209 |
observation = np.array(observation, dtype=np.float32)
|
| 210 |
action_scores = np.dot(observation, self.weights)
|
|
|
|
| 211 |
return int(np.argmax(action_scores))
|
| 212 |
```
|
| 213 |
|
|
|
|
| 224 |
|
| 225 |
**BibTeX:**
|
| 226 |
```bibtex
|
| 227 |
+
@misc{das2025cartpole,
|
| 228 |
author = {Niladri Das},
|
| 229 |
+
title = {CartPole Solution},
|
| 230 |
year = {2025},
|
| 231 |
publisher = {Hugging Face},
|
| 232 |
journal = {Hugging Face Model Hub},
|
| 233 |
+
howpublished = {https://huggingface.co/harpertoken/cartpole-cmaes}
|
|
|
|
| 234 |
}
|