Skip to content

Instantly share code, notes, and snippets.

@sabhiram
Created July 20, 2018 00:48
Show Gist options
  • Save sabhiram/3f5eaf7e566ef9aefb3ae6e5b8d2edb0 to your computer and use it in GitHub Desktop.
Save sabhiram/3f5eaf7e566ef9aefb3ae6e5b8d2edb0 to your computer and use it in GitHub Desktop.
A very simple tensorflow example that demonstrates bad type conversion during py_func results processing
import tensorflow as tf
def test_func(x):
""" Builds a list of ints with length `x`.
"""
return [i for i in range(x)],
def main():
t0 = tf.constant(0, dtype=tf.int64)
t0 = tf.py_func(test_func, [t0], tf.int64)
t1 = tf.constant(1, dtype=tf.int64)
t1 = tf.py_func(test_func, [t1], tf.int64)
with tf.Session() as sess:
sess.run(t1) # OK
sess.run(t0) # 0-th value is double, expects int64
if __name__ == "__main__":
print(tf.GIT_VERSION, tf.VERSION)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment