File size: 1,578 Bytes
cdd6ac7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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:
- SpaceInvadersNoFrameskip-v4
- deep-rl-course
- dqn
- reinforcement-learning
- stable-baselines3
model-index:
- name: DQN
  results:
  - task:
      type: reinforcement-learning
      name: reinforcement-learning
    dataset:
      name: SpaceInvadersNoFrameskip-v4
      type: SpaceInvadersNoFrameskip-v4
    metrics:
    - type: mean_reward
      value: 340.50 +/- 45.20
      name: mean_reward
      verified: false
---

# DQN Agent playing SpaceInvadersNoFrameskip-v4 👾

This is a trained DQN agent playing SpaceInvadersNoFrameskip-v4.
**This model was trained as part of the Hugging Face Deep RL Course Unit 3.**

## Training Details

- **Algorithm**: Deep Q-Network (DQN)
- **Environment**: SpaceInvadersNoFrameskip-v4 (Atari)
- **Library**: Stable Baselines3
- **Training timesteps**: 1,000,000
- **Evaluation**: 340.50 +/- 45.20 (10 episodes)

## Usage

```python
from stable_baselines3 import DQN
from stable_baselines3.common.env_util import make_atari_env
from stable_baselines3.common.vec_env import VecFrameStack

# Create environment
env = make_atari_env('SpaceInvadersNoFrameskip-v4', n_envs=1)
env = VecFrameStack(env, n_stack=4)

# Load the model
model = DQN.load("dqn-SpaceInvadersNoFrameskip-v4", env=env)

# Enjoy trained agent
obs = env.reset()
for i in range(1000):
    action, _states = model.predict(obs, deterministic=True)
    obs, rewards, dones, info = env.step(action)
    env.render()
```

This model achieves good performance on the SpaceInvaders Atari game, scoring well above the target score of 200 for the Deep RL Course Unit 3.