Last active
August 7, 2019 13:10
-
-
Save d3lm/a47f1ab4001457c25c7e604ec798fc4a 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
class Session(): | |
def run(self, operation, feed_dict={}): | |
nodes_sorted = topology_sort(operation) | |
for node in nodes_sorted: | |
if type(node) == Placeholder: | |
node.output = feed_dict[node] | |
elif type(node) == Variable or type(node) == Constant: | |
node.output = node.value | |
else: | |
inputs = [node.output for node in node.input_nodes] | |
node.output = node.forward(*inputs) | |
return operation.output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment