From 8e08709d8221357f4615f792d3f90807eadd2e13 Mon Sep 17 00:00:00 2001 From: Abhinav M Hari <66298497+Thelonenlyhobbist@users.noreply.github.com> Date: Mon, 15 Jun 2020 18:51:25 +0530 Subject: [PATCH 1/2] task2 It took me a while to figure out the convolutions and layers, but now I am good with it. --- Tasks/daily tasks/Abhinav M Hari/task 2.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Tasks/daily tasks/Abhinav M Hari/task 2.py diff --git a/Tasks/daily tasks/Abhinav M Hari/task 2.py b/Tasks/daily tasks/Abhinav M Hari/task 2.py new file mode 100644 index 0000000..e1bdd4c --- /dev/null +++ b/Tasks/daily tasks/Abhinav M Hari/task 2.py @@ -0,0 +1,18 @@ +import torch +import torch.nn as nn + +class Net(nn.Module): + def __init__(self): + super(Net, self). __init__() + self.layer1 = nn.Linear(120, 84) + self.layer2 = nn.Linear(84, 10) + + def forward(self, x): + x = torch.sigmoid(self.layer1(x)) + x = self.layer2(x) + +net = Net() +input = torch.randn(120) +output = net(input) +print(output) + From 77cbfcec4ad31782655b917a58750818243b4b34 Mon Sep 17 00:00:00 2001 From: Abhinav M Hari <66298497+Thelonenlyhobbist@users.noreply.github.com> Date: Mon, 15 Jun 2020 19:06:52 +0530 Subject: [PATCH 2/2] Changing sigmoid function order Just deleted sigmoid function applied to layer 1 and applied sigmoid function to layer 2 --- Tasks/daily tasks/Abhinav M Hari/task 2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/daily tasks/Abhinav M Hari/task 2.py b/Tasks/daily tasks/Abhinav M Hari/task 2.py index e1bdd4c..88e9ef8 100644 --- a/Tasks/daily tasks/Abhinav M Hari/task 2.py +++ b/Tasks/daily tasks/Abhinav M Hari/task 2.py @@ -8,8 +8,8 @@ def __init__(self): self.layer2 = nn.Linear(84, 10) def forward(self, x): - x = torch.sigmoid(self.layer1(x)) - x = self.layer2(x) + x = self.layer1(x) + x = torch.sigmoid(self.layer2(x)) net = Net() input = torch.randn(120)