Deep Q-Network (DQN) Agent playing ALE/SpaceInvaders-v5

This is a trained Deep Q-Network (DQN) agent for the Atari game ALE/SpaceInvaders-v5.

The model was trained using the code available here.

Usage

To load and use this model for inference:

import torch
import json

from model import DQN
from agent import Agent
from environment import make_env, get_env_dims

#Load the configuration
with open("config.json", "r") as f:
    config = json.load(f)

# Create environment. Get action and space dimensions
env = make_env(config)
state_size, action_size = get_env_dims(env)

# Instantiate the agent and load the trained policy network
agent = Agent(state_size, action_size, config)
agent.policy_net.load_state_dict(torch.load("model.pt"))
agent.policy_net.eval()

# Enjoy the agent!
state, _ = env.reset()
done = False
while not done:
    action = agent.act(state, epsilon=0.0) # Act greedily
    state, reward, terminated, truncated, _ = env.step(action)
    done = terminated or truncated
    env.render()
Downloads last month
52
Video Preview
loading

Evaluation results