-
Notifications
You must be signed in to change notification settings - Fork 0
/
learning_model.py
27 lines (23 loc) · 984 Bytes
/
learning_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
import torch.nn as nn
import torch.nn.functional as F
# junk model!
class FLModel(nn.Module):
def __init__(self):
super().__init__()
self.net = nn.Sequential(nn.Linear(79, 128),
nn.BatchNorm1d(128),
nn.ReLU(),
nn.Linear(128, 256),
nn.BatchNorm1d(256),
nn.ReLU(),
nn.Linear(256, 512),
nn.BatchNorm1d(512),
nn.ReLU(),
nn.Linear(512, 512),
nn.BatchNorm1d(512),
nn.ReLU(),
nn.Linear(512, 14)) # 5 layers
def forward(self, x):
x = self.net(x)
output = F.log_softmax(x, dim=1) # use NLLLoss(), which accepts a log probability
return output