-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmy_nn.py
35 lines (30 loc) · 1.04 KB
/
my_nn.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
import torch.nn as nn
# Fully connected neural network
class NeuralNetCLS(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(NeuralNetCLS, self).__init__()
self.linear_relu_stack = nn.Sequential(
nn.Linear(input_size, hidden_size),
nn.ReLU(),
nn.Linear(hidden_size, hidden_size),
nn.ReLU(),
nn.Linear(hidden_size, output_size),
# nn.Sigmoid(),
)
def forward(self, x):
out = self.linear_relu_stack(x)
return out
class NeuralNetDIR(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(NeuralNetDIR, self).__init__()
self.linear_relu_stack = nn.Sequential(
nn.Linear(input_size, hidden_size),
nn.ReLU(),
nn.Linear(hidden_size, hidden_size),
nn.ReLU(),
nn.Linear(hidden_size, output_size),
nn.ReLU(),
)
def forward(self, x):
out = self.linear_relu_stack(x)
return out