File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ import pytest
2+ import torch
3+ import torch .nn as nn
4+
5+ """
6+ Multi-layer perceptron model for image classification.
7+ """
8+
9+ # class NeuronLayer(nn.Module):
10+ # def __init__(self, in_features, out_features):
11+ # super().__init__()
12+
13+ # self.fc = nn.Linear(in_features, out_features)
14+ # self.relu = nn.ReLU()
15+
16+ # def forward(self, x):
17+ # x = self.fc(x)
18+ # x = self.relu(x)
19+ # return x
20+
21+ class JohanModel (nn .Module ):
22+ """Small MLP model for image classification.
23+
24+ Parameters
25+ ----------
26+ in_features : int
27+ Numer of input features.
28+ num_classes : int
29+ Number of classes in the dataset.
30+
31+ """
32+ def __init__ (self , in_features , num_classes ):
33+ super ().__init__ ()
34+
35+ self .fc1 = nn .Linear (in_features , 77 )
36+ self .fc2 = nn .Linear (77 , 77 )
37+ self .fc3 = nn .Linear (77 , 77 )
38+ self .fc4 = nn .Linear (77 , num_classes )
39+ self .softmax = nn .Softmax (dim = 1 )
40+ self .relu = nn .ReLU ()
41+
42+ def forward (self , x ):
43+ for layer in [self .fc1 , self .fc2 , self .fc3 , self .fc4 ]:
44+ x = layer (x )
45+ x = self .relu (x )
46+ x = self .softmax (x )
47+ return x
48+
49+
50+
51+ #TODO
52+ # Add your tests here
53+
54+
55+ if __name__ == "__main__" :
56+ pass # Add your tests here
You can’t perform that action at this time.
0 commit comments