diff --git a/Tasks/daily tasks/Ananthu Ajay/day4.py b/Tasks/daily tasks/Ananthu Ajay/day4.py new file mode 100644 index 0000000..27f3300 --- /dev/null +++ b/Tasks/daily tasks/Ananthu Ajay/day4.py @@ -0,0 +1,32 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F + + +class Net(nn.Module): + + def __init__(self): + super(Net, self).__init__() + self.conv1 = nn.Conv2d(1, 4, 4) + self.conv2 = nn.Conv2d(4, 16, 4) + self.fc1 = nn.Linear(16 * 4 * 4, 120) + self.fc2 = nn.Linear(120, 10) + + def forward(self, x): + x = F.max_pool2d(F.sigmoid(self.conv1(x)), (2, 2)) + x = F.max_pool2d(F.sigmoid(self.conv2(x)), 2) + x = x.view(-1, self.num_flat_features(x)) + x = F.sigmoid(self.fc1(x)) + x = self.fc2(x) + return x + + def num_flat_features(self, x): + size = x.size()[1:] + num_features = 1 + for s in size: + num_features *= s + return num_features + + +net = Net() +print(net)