Skip to content

Instantly share code, notes, and snippets.

@AndreCAndersen
Last active June 18, 2017 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreCAndersen/d65878c1445c4decf06ae1fb61a32a9f to your computer and use it in GitHub Desktop.
Save AndreCAndersen/d65878c1445c4decf06ae1fb61a32a9f to your computer and use it in GitHub Desktop.
Testing of map_fn in tensorflow
import tensorflow as tf
f1 = lambda x: x*1
f2 = lambda x: x*2
f3 = lambda x: x*3
x = [f1, f2, f3]
y = [1, 2, 3]
result = list(map(lambda x,y: x(y), x, y))
print(result)
# [1, 4, 9]
y = tf.constant([1, 2, 3])
f = tf.map_fn(lambda x,y: x(y), (x, y))
sess = tf.Session()
result = sess.run(f)
print(result)
# TypeError: Expected binary or unicode string, got <function <lambda> at 0x00000190E9C31C80>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment