Skip to content

Instantly share code, notes, and snippets.

@d3lm
Last active August 7, 2019 13:10
Show Gist options
  • Save d3lm/a47f1ab4001457c25c7e604ec798fc4a to your computer and use it in GitHub Desktop.
Save d3lm/a47f1ab4001457c25c7e604ec798fc4a to your computer and use it in GitHub Desktop.
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