-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmpnet_models.py
66 lines (54 loc) · 2.37 KB
/
mpnet_models.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
''' Define MPNet models for planning.
# Obtained from - https://github.com/anthonysimeonov/baxter_mpnet_experiments/blob/master/architectures.py
'''
import torch
import torch.nn as nn
import torchvision.models as models
from torch.nn.utils.rnn import pack_padded_sequence
from torch.autograd import Variable
# DMLP Model-Path Generator
class MLP(nn.Module):
def __init__(self, input_size, output_size):
super(MLP, self).__init__()
self.fc = nn.Sequential(
nn.Linear(input_size, 1280), nn.PReLU(), nn.Dropout(),
nn.Linear(1280, 896), nn.PReLU(), nn.Dropout(),
nn.Linear(896, 512), nn.PReLU(), nn.Dropout(),
nn.Linear(512, 384), nn.PReLU(), nn.Dropout(),
nn.Linear(384, 256), nn.PReLU(), nn.Dropout(),
nn.Linear(256, 128), nn.PReLU(), nn.Dropout(),
nn.Linear(128, 64), nn.PReLU(), nn.Dropout(),
nn.Linear(64, 32), nn.PReLU(),
nn.Linear(32, output_size))
def forward(self, x):
out = self.fc(x)
return out
# class MLP_Path(nn.Module):
# def __init__(self, input_size, output_size):
# super(MLP_Path, self).__init__()
# self.fc = nn.Sequential(
# nn.Linear(input_size, 512), nn.PReLU(), nn.Dropout(),
# nn.Linear(512, 512), nn.PReLU(), nn.Dropout(),
# nn.Linear(512, output_size))
# def forward(self, x):
# out = self.fc(x)
# return out
class Encoder(nn.Module):
def __init__(self, input_size, output_size):
super(Encoder, self).__init__()
self.encoder = nn.Sequential(nn.Linear(input_size, 786), nn.PReLU(),
nn.Linear(786, 512), nn.PReLU(),
nn.Linear(512, 256), nn.PReLU(),
nn.Linear(256, output_size))
def forward(self, x):
x = self.encoder(x)
return x
class Encoder_End2End(nn.Module):
def __init__(self, input_size, output_size):
super(Encoder_End2End, self).__init__() #16053 input, 60 output usually
self.encoder = nn.Sequential(nn.Linear(input_size, 256), nn.PReLU(),
nn.Linear(256, 256), nn.PReLU(),
nn.Linear(256, output_size))
def forward(self, x):
x = self.encoder(x)
return x