-
Notifications
You must be signed in to change notification settings - Fork 0
/
extempauto.py
45 lines (39 loc) · 1.13 KB
/
extempauto.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
import torch.nn as nn
class ExTempAuto(nn.Module):
def __init__(self):
super().__init__()
self.encoder = nn.Sequential(
nn.Linear(1440, 1024),
nn.LeakyReLU(),
nn.Linear(1024, 512),
nn.LeakyReLU(),
nn.Linear(512, 256),
nn.LeakyReLU(),
)
self.classifier = nn.Sequential(
nn.Linear(256, 128),
nn.LeakyReLU(),
nn.Linear(128, 64),
nn.LeakyReLU(),
nn.Linear(64, 32),
nn.LeakyReLU(),
nn.Linear(32, 16),
nn.LeakyReLU(),
nn.Linear(16, 8),
nn.LeakyReLU(),
nn.Linear(8, 4),
nn.Softmax(1),
)
self.decoder = nn.Sequential(
nn.Linear(256, 512),
nn.LeakyReLU(),
nn.Linear(512, 1024),
nn.LeakyReLU(),
nn.Linear(1024, 1440),
nn.Sigmoid(),
)
def forward(self, x):
encoded = self.encoder(x)
softmax = self.classifier(encoded)
decoded = self.decoder(encoded)
return softmax, decoded