Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Tasks/daily tasks/Ananthu Ajay/day4.py
Original file line number Diff line number Diff line change
@@ -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)