Created
May 7, 2019 18:56
-
-
Save chaserileyroberts/4935b6ac2f804694bbb7e7b084d71e35 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
import tensorflow as tf | |
tf.enable_v2_behavior() | |
def outer_product(x): | |
return tf.tensordot(x, x, 0) | |
val = tf.ones((1000, 32, 32)) | |
%timeit tf.map_fn(outer_product, val) | |
# >>> 1 loops, best of 3: 849 ms per loop | |
%timeit tf.vectorized_map(outer_product, val) | |
# >>> 10 loops, best of 3: 37.8 ms per loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment