-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
32 lines (30 loc) · 898 Bytes
/
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
import torch.nn as nn
class CNNModel(nn.Module):
def __init__(self):
super().__init__()
self.encoder = nn.Sequential(
nn.Conv1d(1, 16, 3, padding=1),
nn.BatchNorm1d(16),
nn.ReLU(),
nn.MaxPool1d(2),
nn.Conv1d(16, 32, 3, padding=1),
nn.BatchNorm1d(32),
nn.ReLU(),
nn.MaxPool1d(2),
nn.Conv1d(32, 64, 3, padding=1),
nn.BatchNorm1d(64),
nn.ReLU(),
nn.MaxPool1d(2),
nn.Flatten()
)
self.predictor = nn.Sequential(
nn.Linear(150*64, 1000),
nn.BatchNorm1d(1000),
nn.ReLU(),
nn.Linear(1000, 100),
nn.BatchNorm1d(100),
nn.ReLU(),
nn.Linear(100, 4)
)
def forward(self, x):
return self.predictor(self.encoder(x))