rigupta/Hackathon
0
1import math2import torch3import torchvision4import torch.nn as nn5import torch.nn.functional as F6from torchvision import transforms7# Add more imports if required8 9# Sample Transformation function10# YOUR CODE HERE for changing the Transformation values.11trnscm = transforms.Compose([transforms.Resize((100,100)), transforms.ToTensor()])12 13##Example Network14class Siamese(torch.nn.Module):15 def __init__(self):16 super(Siamese, self).__init__()17 #YOUR CODE HERE18 self.cnn1 = nn.Sequential(19 nn.ReflectionPad2d(1), #Pads the input tensor using the reflection of the input boundary, it similar to the padding.20 nn.Conv2d(1, 4, kernel_size=3),21 nn.ReLU(inplace=True),22 nn.BatchNorm2d(4),23 24 nn.ReflectionPad2d(1),25 nn.Conv2d(4, 8, kernel_size=3),26 nn.ReLU(inplace=True),27 nn.BatchNorm2d(8),28 29 30 nn.ReflectionPad2d(1),31 nn.Conv2d(8, 8, kernel_size=3),32 nn.ReLU(inplace=True),33 nn.BatchNorm2d(8),34 )35 self.fc1 = nn.Sequential(36 nn.Linear(8*100*100, 500),37 nn.ReLU(inplace=True),38 39 nn.Linear(500, 500),40 nn.ReLU(inplace=True),41 42 nn.Linear(500, 5))43 44 def forward_once(self, x):45 output = self.cnn1(x)46 output = output.view(output.size()[0], -1)47 output = self.fc1(output)48 return output49 50 def forward(self, x):51 #pass # remove 'pass' once you have written your code52 #YOUR CODE HERE53 output1 = self.forward_once(input1)54 output2 = self.forward_once(input2)55 return output1, output256##########################################################################################################57## Sample classification network (Specify if you are using a pytorch classifier during the training) ##58## classifier = nn.Sequential(nn.Linear(64, 64), nn.BatchNorm1d(64), nn.ReLU(), nn.Linear...) ##59##########################################################################################################60 61# YOUR CODE HERE for pytorch classifier62 63# Definition of classes as dictionary64classes = ['person1','person2','person3','person4','person5','person6','person7']