-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnn.py
More file actions
26 lines (17 loc) · 707 Bytes
/
nn.py
File metadata and controls
26 lines (17 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
This script builds and runs a graph with miniflow.
There is no need to change anything to solve this quiz!
However, feel free to play with the network! Can you also
build a network that solves the equation below?
(x + y) + y
"""
from miniflow import *
x, y, z = Input(), Input(), Input()
f = Add(x, y, z)
g = Mul(x, y, z)
feed_dict = {x: 4, y: 5, z: 10}
sorted_nodes = topological_sort(feed_dict)
output = forward_pass(f, sorted_nodes)
# should output 19
print("{} + {} + {} = {} (according to miniflow)".format(feed_dict[x], feed_dict[y], feed_dict[z], output))
print("{} * {} * {} = {} (according to miniflow)".format(feed_dict[x], feed_dict[y], feed_dict[z], forward_pass(g, sorted_nodes)))