File tree 1 file changed +3
-5
lines changed
beginner_source/examples_nn 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change 16
16
class DynamicNet (torch .nn .Module ):
17
17
def __init__ (self ):
18
18
"""
19
- In the constructor we instantiate four parameters and assign them as
20
- member variables.
19
+ In the constructor we instantiate five parameters and assign them as members.
21
20
"""
22
21
super ().__init__ ()
23
22
self .a = torch .nn .Parameter (torch .randn (()))
@@ -35,9 +34,8 @@ def forward(self, x):
35
34
Python control-flow operators like loops or conditional statements when
36
35
defining the forward pass of the model.
37
36
38
- Here we also see that it is perfectly safe to reuse the same Module many
39
- times when defining a computational graph. This is a big improvement from Lua
40
- Torch, where each Module could be used only once.
37
+ Here we also see that it is perfectly safe to reuse the same parameter many
38
+ times when defining a computational graph.
41
39
"""
42
40
y = self .a + self .b * x + self .c * x ** 2 + self .d * x ** 3
43
41
for exp in range (4 , random .randint (4 , 6 )):
You can’t perform that action at this time.
0 commit comments