Downloads · 30 days
0
arabellako22/lunarlander-v3-dqn-scratch
lunarlander-v3-dqn-scratch is a reinforcement learning model from arabellako22. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product.
This repository contains a PyTorch implementation of a Deep Q-Network (DQN) built from scratch to solve the LunarLander-v3 environment from Gymnasium.
Downloads · 30 days
0
Access
Public
Updated Aug 23, 2026
Repo size
45.2 KB
Likes
0
Public
Click a slice to open those files.
.mp458.3 KB · 68%
From the Hugging Face model README
This repository contains a PyTorch implementation of a Deep Q-Network (DQN) built from scratch to solve the LunarLander-v3 environment from Gymnasium.
https://huggingface.co/arabellako22/lunarlander-v3-dqn-scratch/resolve/main/replay.mp4
<video controls autoplay loop> <source src="https://huggingface.co/arabellako22/lunarlander-v3-dqn-scratch/resolve/main/replay.mp4" type="video/mp4"> </video>import torch
import gymnasium as gym
from model import QNetwork
# Initialize environment and load weights
env = gym.make("LunarLander-v3", render_mode="human")
model = QNetwork(state_size=8, action_size=4)
model.load_state_dict(torch.load("model.pt", map_location="cpu"))
model.eval()
state, _ = env.reset()
done = False
while not done:
state_tensor = torch.from_numpy(state).float().unsqueeze(0)
with torch.no_grad():
action = torch.argmax(model(state_tensor)).item()
state, reward, terminated, truncated, _ = env.step(action)
done = terminated or truncated
env.close()