Commit 603051ba authored by Mirza Cutuk's avatar Mirza Cutuk
Browse files

GROUPWORK_added comments

parent f5b83afd
......@@ -10,7 +10,7 @@ from torch.nn.modules.dropout import Dropout
from torch.nn.modules.pooling import MaxPool2d
# import matplotlib.pyplot as plt
## Basic Model
## Basic MLP Network with 2 hidden layers
class NN(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......@@ -30,6 +30,7 @@ class NN(nn.Module):
x = self.classifier(x)
return x
## VGG Convolutional Network with 2 hidden layers
class CNN_VGG(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......@@ -67,6 +68,7 @@ class CNN_VGG(nn.Module):
#Problem 1 Part 2:
## 2 Networks: Classifier + Comparer (Weight Sharing)
## MLP Network with 2 hidden layers for classification only
class NN_Classification(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......@@ -86,6 +88,7 @@ class NN_Classification(nn.Module):
x2 = self.classifier(x2.view(-1, 196))
return torch.cat((x1, x2), 1)
## Convolutional Network with 2 hidden layers for classification only
class CNN_Classification(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......@@ -126,7 +129,7 @@ class CNN_Classification(nn.Module):
x2 = self.classifier(x2)
return torch.cat((x1, x2), 1)
## MLP Network with 2 hidden layers for comparison only
class MLP_Comparer(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......@@ -145,11 +148,10 @@ class MLP_Comparer(nn.Module):
)
def forward(self, x):
# x = self.classifier(torch.cat((x1, x2), 1))
x = self.classifier(x)
# return torch.cat((x1, x2), 1)
return x
## MLP Siamese Network with classification and comparison combined
class NN_WS(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......@@ -160,6 +162,7 @@ class NN_WS(nn.Module):
x = self.comparer(self.classifier(x[:, 0], x[:,1]))
return x
## Convolutional Siamese Network with classification and comparison combined
class CNN_WS(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......@@ -167,12 +170,10 @@ class CNN_WS(nn.Module):
self.comparer = MLP_Comparer(nb_hidden)
def forward(self, x):
# x = self.classifier(torch.cat((x1, x2), 1))
x = self.comparer(self.classifier(x[:, 0], x[:,1]))
# return torch.cat((x1, x2), 1)
return x
## NN WS+AL
## MLP Siamese Network with classification and comparison combined + Auxiliary Loss
class NN_WS_AL(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......@@ -187,7 +188,7 @@ class NN_WS_AL(nn.Module):
# keep both, for Auxiliary Loss
return out, res
## CNN WS + AL
## Convolutional Siamese Network with classification and comparison combined + Auxiliary Loss
class CNN_WS_AL(nn.Module):
def __init__(self, nb_hidden):
super().__init__()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment