Skip to content

Commit 6c2301f

Browse files
committed
Added skeleton of johan_model
1 parent 71957eb commit 6c2301f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

utils/models/johan_model.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

0 commit comments

Comments
 (0)