Skip to content

Commit 27745ca

Browse files
authored
Merge pull request #79 from AnanthuAjay/patch-3
Create day4.py
2 parents 37b1409 + e1700f4 commit 27745ca

File tree

1 file changed

+32
-0
lines changed
  • Tasks/daily tasks/Ananthu Ajay

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import torch
2+
import torch.nn as nn
3+
import torch.nn.functional as F
4+
5+
6+
class Net(nn.Module):
7+
8+
def __init__(self):
9+
super(Net, self).__init__()
10+
self.conv1 = nn.Conv2d(1, 4, 4)
11+
self.conv2 = nn.Conv2d(4, 16, 4)
12+
self.fc1 = nn.Linear(16 * 4 * 4, 120)
13+
self.fc2 = nn.Linear(120, 10)
14+
15+
def forward(self, x):
16+
x = F.max_pool2d(F.sigmoid(self.conv1(x)), (2, 2))
17+
x = F.max_pool2d(F.sigmoid(self.conv2(x)), 2)
18+
x = x.view(-1, self.num_flat_features(x))
19+
x = F.sigmoid(self.fc1(x))
20+
x = self.fc2(x)
21+
return x
22+
23+
def num_flat_features(self, x):
24+
size = x.size()[1:]
25+
num_features = 1
26+
for s in size:
27+
num_features *= s
28+
return num_features
29+
30+
31+
net = Net()
32+
print(net)

0 commit comments

Comments
 (0)