Views
No views yet
Gymnasium Box2DLunarLander-v3Reinforcement Learning Agent & Real-time Aerospace Telemetry System
🌐 English Documentation | 🇰🇷 한국어 매뉴얼
LunarLander-v3 environment.best_model.pth: Pre-trained PyTorch Dueling Double DQN neural network weights (+311.16 score).config.json: Model architecture, hyperparameters, and environment specifications.dqn_agent.py: Complete PyTorch source code for DQNAgent and DuelingQNetwork.README.md: Global English Model Card and evaluation guide.README_KR.md: Full Korean comprehensive manual and telemetry specifications.0: IDLE (Coast)1: Fire Left Thruster2: Fire Main Engine Thruster3: Fire Right Thruster| Hyperparameter | Value | Description |
|---|---|---|
| Learning Rate | 5e-4 | AdamW optimizer learning rate |
| Discount Factor ($\gamma$) | 0.99 | Future reward discount factor |
| Replay Buffer Size | 100,000 | Experience replay memory capacity |
| Batch Size | 64 | Mini-batch sample size for training |
| Target Network Update ($\tau$) | 0.001 | Polyak soft update rate |
| Exploration ($\epsilon$) | 1.0 \to 0.05 | 100% exploration decaying to 5% |
1import torch
2import torch.nn as nn
3import gymnasium as gym
4
5# 1. Define Dueling DQN Architecture
6class DuelingDQN(nn.Module):
7 def __init__(self, state_dim=8, action_dim=4):
8 super().__init__()
9 self.feature_network = nn.Sequential(
10 nn.Linear(state_dim, 128),
11 nn.LayerNorm(128),
12 nn.ReLU(),
13 nn.Linear(128, 128),
14 nn.LayerNorm(128),
15 nn.ReLU(),
16 )
17 self.value_stream = nn.Sequential(
18 nn.Linear(128, 64),
19 nn.ReLU(),
20 nn.Linear(64, 1)
21 )
22 self.advantage_stream = nn.Sequential(
23 nn.Linear(128, 64),
24 nn.ReLU(),
25 nn.Linear(64, action_dim)
26 )
27
28 def forward(self, state):
29 features = self.feature_network(state)
30 values = self.value_stream(features)
31 advantages = self.advantage_stream(features)
32 return values + (advantages - advantages.mean(dim=-1, keepdim=True))
33
34# 2. Download weights from Hugging Face Hub
35from huggingface_hub import hf_hub_download
36
37weights_path = hf_hub_download(repo_id="hwihwalab/lunarlander-v3-d3qn", filename="best_model.pth")
38device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
39
40model = DuelingDQN().to(device)
41model.load_state_dict(torch.load(weights_path, map_location=device))
42model.eval()
43
44# 3. Test Agent Flight
45env = gym.make("LunarLander-v3", render_mode="human")
46state, _ = env.reset()
47total_reward = 0
48
49for _ in range(1000):
50 state_t = torch.FloatTensor(state).unsqueeze(0).to(device)
51 with torch.no_grad():
52 action = model(state_t).argmax(dim=-1).item()
53
54 state, reward, terminated, truncated, _ = env.step(action)
55 total_reward += reward
56 if terminated or truncated:
57 break
58
59print(f"Final Flight Reward: {total_reward:.2f}")
60env.close()