2024-05-25 16:33:34 +02:00
|
|
|
import torch.nn as nn
|
2024-05-25 18:41:25 +02:00
|
|
|
import torch
|
|
|
|
import torch.nn.functional as F
|
2024-05-25 16:33:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Neural_Network_Model(nn.Module):
|
|
|
|
def __init__(self, num_classes=5,hidden_layer1 = 100,hidden_layer2 = 100):
|
|
|
|
super(Neural_Network_Model, self).__init__()
|
|
|
|
self.fc1 = nn.Linear(150*150*3,hidden_layer1)
|
|
|
|
self.fc2 = nn.Linear(hidden_layer1,hidden_layer2)
|
|
|
|
self.out = nn.Linear(hidden_layer2,num_classes)
|
|
|
|
# two hidden layers
|
|
|
|
|
|
|
|
def forward(self, x):
|
|
|
|
x = x.view(-1, 150*150*3)
|
|
|
|
x = self.fc1(x)
|
|
|
|
x = torch.relu(x)
|
|
|
|
x = self.fc2(x)
|
|
|
|
x = torch.relu(x)
|
|
|
|
x = self.out(x)
|
2024-05-25 18:41:25 +02:00
|
|
|
return F.log_softmax(x, dim=-1)
|