Downloads · 30 days
0
Bharateesha/custom-dqn-space-invaders
custom-dqn-space-invaders is a machine learning model from Bharateesha. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains a custom Convolutional Neural Network (CNN) trained using Deep Q-Learning completely implemented from scratch in pure PyTorch.
Downloads · 30 days
0
Access
Public
Updated Jun 26, 2026
Repo size
6.8 MB
Likes
0
Public
Click a slice to open those files.
.pt6.8 MB · 100%
From the Hugging Face model README
This repository contains a custom Convolutional Neural Network (CNN) trained using Deep Q-Learning completely implemented from scratch in pure PyTorch.
class AtariDQN(nn.Module):
def __init__(self, n_actions):
super(AtariDQN, self).__init__()
# 1. Feature Extractor (Scans 4 stacked gray image channels)
self.cnn = nn.Sequential(
nn.Conv2d(4, 32, kernel_size=8, stride=4),
nn.ReLU(),
nn.Conv2d(32, 64, kernel_size=4, stride=2),
nn.ReLU(),
nn.Conv2d(64, 64, kernel_size=3, stride=1),
nn.ReLU(),
nn.Flatten()
)
# 2. Fully Connected Classifier Layers (Predicts action scores)
self.fc = nn.Sequential(
nn.Linear(64 * 7 * 7, 512),
nn.ReLU(),
nn.Linear(512, n_actions) # <--- Cleaned up to match 'n_actions' perfectly
)
def forward(self, x):
# Scale pixels from [0, 255] down to float standard [0.0, 1.0]
return self.fc(self.cnn(x / 255.0))