Downloads · 30 days
10
10% of all-time downloads
giansimone/DQN-ALE-SpaceInvaders
DQN-ALE-SpaceInvaders is a reinforcement learning model from giansimone. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product.
This is a trained Deep Q-Network (DQN) agent for the Atari game ALE/SpaceInvaders-v5.
Downloads · 30 days
10
10% of all-time downloads
All-time downloads
102
Public
Repo size
14.2 MB
Likes
0
Public
Click a slice to open those files.
.pt6.8 MB · 97%
From the Hugging Face model README
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.
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()