Last active
May 26, 2020 20:38
-
-
Save tswedish/f981f89d0cc8d2133a4026c59f8a1496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def forward_fn(x): | |
for n in range(5): | |
if n % 2 == 0: | |
x = 3.*x | |
else: | |
x = x**(1./n) + 1./n | |
return x | |
x = Variable(2.) | |
y = forward_fn(x) | |
print(y) | |
y.backward() | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment