-
Notifications
You must be signed in to change notification settings - Fork 0
/
imitation_learning_policy_model.py
39 lines (32 loc) · 1.21 KB
/
imitation_learning_policy_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import torch
from torch import nn
import torch.nn.functional as F
from torchvision import transforms as tfms
class Behaviour_cloning_model(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(3, 24, 5, 2)
self.conv2 = nn.Conv2d(24, 36, 5, 2)
self.conv3 = nn.Conv2d(36, 48, 5, 2)
self.conv4 = nn.Conv2d(48, 64, 3, 1)
self.conv5 = nn.Conv2d(64, 64, 3, 1)
self.dense = nn.Sequential(nn.Linear(1152, 100),
nn.ELU(),
nn.Dropout(0.25),
nn.Linear(100, 50),
nn.ELU(),
nn.Linear(50, 10),
nn.ELU(),
nn.Linear(10, 1))
def forward(self, x):
batch_size = x.size(0)
# Convolutional Pass
x = F.elu(self.conv1(x))
x = F.elu(self.conv2(x))
x = F.elu(self.conv3(x))
x = F.elu(self.conv4(x))
x = F.elu(self.conv5(x))
# Linear Pass
x = x.reshape(batch_size, -1)
out = self.dense(x)
return out