-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
32 lines (22 loc) · 841 Bytes
/
models.py
File metadata and controls
32 lines (22 loc) · 841 Bytes
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
import torch.nn as nn
import torch.optim as optim
class ANNModel(nn.Module):
def __init__(self, input_dim, layer1=32, layer2=48, output_dim=1,
drop_rate=0.5):
super().__init__()
self.input_dim = input_dim
self.output_dim = output_dim
self.layer1 = layer1
self.layer2 = layer2
self.drop_rate = drop_rate
self.fc1 = nn.Linear(self.input_dim, self.layer1, )
self.fc2 = nn.Linear(self.layer1, self.layer2)
self.fc3 = nn.Linear(self.layer2, self.output_dim)
self.dropout = nn.Dropout(self.drop_rate)
self.activation = nn.ReLU()
def forward(self, x):
x = self.activation(self.fc1(x))
x = self.activation(self.dropout(self.fc2(x)))
x = self.fc3(x)
return x