Created
October 18, 2018 08:52
-
-
Save DerekChia/4a208ef88d3a085145b4da479872686f 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
a = tf.constant([10, 20]) | |
b = tf.constant([1.0, 2.0]) | |
# 'fetches' can be a singleton | |
v = session.run(a) | |
# v is the numpy array [10, 20] | |
# 'fetches' can be a list. | |
v = session.run([a, b]) | |
# v is a Python list with 2 numpy arrays: the 1-D array [10, 20] and the | |
# 1-D array [1.0, 2.0] | |
# 'fetches' can be arbitrary lists, tuples, namedtuple, dicts: | |
MyData = collections.namedtuple('MyData', ['a', 'b']) | |
v = session.run({'k1': MyData(a, b), 'k2': [b, a]}) | |
# v is a dict with | |
# v['k1'] is a MyData namedtuple with 'a' (the numpy array [10, 20]) and | |
# 'b' (the numpy array [1.0, 2.0]) | |
# v['k2'] is a list with the numpy array [1.0, 2.0] and the numpy array | |
# [10, 20]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment