Skip to content

Commit 9c6836a

Browse files
committed
[example][add_eq] add reverse computation in example
1 parent ea51328 commit 9c6836a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

example/add_eq.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@
3535
dy = np.zeros(m)
3636

3737
dx[0] = 1.
38-
print("x")
3938
dy = f.Forward(1 ,dx)
4039
assert(dy[0] == 2.)
4140
assert(dy[1] == 2.)
4241

43-
print("y")
42+
# reverse computation of derivative of y[0]
43+
w = np.zeros((m,))
44+
dw = np.zeros((n),)
45+
46+
w[0] = 1.
47+
w[1] = 0.
48+
dw = f.Reverse(1, w)
49+
50+
assert(dw[0] == 2.)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy