-
Notifications
You must be signed in to change notification settings - Fork 3
/
Net.py
executable file
·48 lines (40 loc) · 1.39 KB
/
Net.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
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.rnn import PackedSequence
import numpy
class NetVCM(nn.Module):
def __init__(self, nInput, nHidden, nOutput):
super(NetVCM, self).__init__()
self.fc1 = nn.Linear(nInput, nHidden)
self.fc2 = nn.Linear(nHidden, nHidden)
self.fc3 = nn.Linear(nHidden, nHidden)
self.fc4 = nn.Linear(nHidden, nOutput)
def forward(self, x):
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = F.relu(self.fc3(x))
x = self.fc4(x)
return F.softmax(x, dim=1)
class NetLing(nn.Module):
def __init__(self, nInput, nHidden, nOutput):
super(NetLing, self).__init__()
self.fc1 = nn.Linear(nInput, nHidden)
self.fc2 = nn.Linear(nHidden, nHidden)
self.fc3 = nn.Linear(nHidden, nOutput)
def forward(self, x):
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return F.softmax(x, dim=1)
class NetSyll(nn.Module):
def __init__(self, nInput, nHidden, nOutput):
super(NetSyll, self).__init__()
self.fc1 = nn.Linear(nInput, nHidden)
self.fc2 = nn.Linear(nHidden, nHidden)
self.fc3 = nn.Linear(nHidden, nOutput)
def forward(self, x):
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return F.softmax(x, dim=1)