-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDQN.py
More file actions
25 lines (20 loc) · 755 Bytes
/
Copy pathDQN.py
File metadata and controls
25 lines (20 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import torch
import torch.nn as nn
import torch.nn.functional as nnFunc
# DQN algorithm
# -------------
class DQN(nn.Module):
def __init__(self):
super(DQN, self).__init__()
self.conv1 = nn.Conv2d(3, 16, kernel_size=5, stride=2)
self.bn1 = nn.BatchNorm2d(16)
self.conv2 = nn.Conv2d(16, 32, kernel_size=5, stride=2)
self.bn2 = nn.BatchNorm2d(32)
self.conv3 = nn.Conv2d(32, 32, kernel_size=5, stride=2)
self.bn3 = nn.BatchNorm2d(32)
self.head = nn.Linear(448, 2)
def forward(self, x):
x = nnFunc.relu(self.bn1(self.conv1(x)))
x = nnFunc.relu(self.bn2(self.conv2(x)))
x = nnFunc.relu(self.bn3(self.conv3(x)))
return self.head(x.view(x.size(0), -1))