File size: 1,492 Bytes
5cb9176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
tags:
- MountainCar-v0
- deep-reinforcement-learning
- reinforcement-learning
model-index:
- name: QDQN
  results:
  - task:
      type: reinforcement-learning
      name: reinforcement-learning
    dataset:
      name: MountainCar-v0
      type: MountainCar-v0
    metrics:
    - type: mean_reward
      value: -200.0 +/- 0.0
      name: mean_reward
      verified: false
---

# **QDQN** Agent playing **MountainCar-v0**
This is a trained model of a **QDQN** agent playing **MountainCar-v0**
using the [qrl-dqn-gym](https://github.com/qdevpsi3/qrl-dqn-gym). 

This agent has been trained for the [research project](https://github.com/agercas/QHack2023_QRL) during the QHack 2023 
hackathon. The project explores the use of quantum algorithms in reinforcement learning. 
More details about the project and the trained agent can be found in the [project repository](https://github.com/agercas/QHack2023_QRL).


## Usage

```python
import gym
import yaml
import torch
from model.qnn import QuantumNet
from model.agent import Agent

# Environment
env_name = 'MountainCar-v0'
env = gym.make(env_name)

# Network
with open('config.yaml', 'r') as f:
  hparams = yaml.safe_load(f)

net = QuantumNet(
    n_layers=hparams['n_layers'], 
    w_input=hparams['w_input'], 
    w_output=hparams['w_output'],
    data_reupload=hparams['data_reupload']
)
state_dict = torch.load('qdqn-MountainCar-v0.pt', map_location=torch.device('cpu'))
net.load_state_dict(state_dict)

# Agent
agent = Agent(net)
```