File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Tasks/daily tasks/Ananthu Ajay Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments