cleanrl tensorboard CartPole-v1 deep-reinforcement-learning reinforcement-learning custom-implementation model-index region:us
---
tags:
- CartPole-v1
- deep-reinforcement-learning
- reinforcement-learning
- custom-implementation
library_name: cleanrl
model-index:
- name: DQN
  results:
  - task:
      type: reinforcement-learning
      name: reinforcement-learning
    dataset:
      name: CartPole-v1
      type: CartPole-v1
    metrics:
    - type: mean_reward
      value: 438.60 +/- 87.15
      name: mean_reward
      verified: false
---

# (CleanRL) **DQN** Agent Playing **CartPole-v1**

This is a trained model of a DQN agent playing CartPole-v1.
The model was trained by using [CleanRL](https://github.com/vwxyzjn/cleanrl) and the most up-to-date training code can be
found [here](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn.py).

## Get Started

To use this model, please install the `cleanrl` package with the following command:

```
pip install "cleanrl[dqn]"
python -m cleanrl_utils.enjoy --exp-name dqn --env-id CartPole-v1
```

Please refer to the [documentation](https://docs.cleanrl.dev/get-started/zoo/) for more detail.


## Command to reproduce the training

```bash
curl -OL https://huggingface.co/nsanghi/CartPole-v1-dqn-seed1/raw/main/dqn.py
curl -OL https://huggingface.co/nsanghi/CartPole-v1-dqn-seed1/raw/main/pyproject.toml
curl -OL https://huggingface.co/nsanghi/CartPole-v1-dqn-seed1/raw/main/poetry.lock
poetry install --all-extras
python dqn.py --seed 1 --env-id CartPole-v1 --total-timesteps 50000 --track --capture-video --save-model --upload-model --hf-entity nsanghi
```

# Hyperparameters
```python
{'batch_size': 128,
 'buffer_size': 10000,
 'capture_video': True,
 'cuda': True,
 'end_e': 0.05,
 'env_id': 'CartPole-v1',
 'exp_name': 'dqn',
 'exploration_fraction': 0.5,
 'gamma': 0.99,
 'hf_entity': 'nsanghi',
 'learning_rate': 0.00025,
 'learning_starts': 10000,
 'num_envs': 1,
 'save_model': True,
 'seed': 1,
 'start_e': 1,
 'target_network_frequency': 500,
 'tau': 1.0,
 'torch_deterministic': True,
 'total_timesteps': 50000,
 'track': True,
 'train_frequency': 10,
 'upload_model': True,
 'wandb_entity': None,
 'wandb_project_name': 'cleanRL'}
```
    