Skip to content

Instantly share code, notes, and snippets.

@poweic
Created April 25, 2019 23:27
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 poweic/2a889de03b0a7f112d7fa8bc5e2143a9 to your computer and use it in GitHub Desktop.
Save poweic/2a889de03b0a7f112d7fa8bc5e2143a9 to your computer and use it in GitHub Desktop.
Code snippet to recreate memory leak bug when .map is used with AUTOTUNE
#! /usr/bin/env python3
import tensorflow as tf
zeros = [0] * 10
dataset = (
tf.data.Dataset.from_tensor_slices(zeros)
.map(lambda x: x, num_parallel_calls=tf.data.experimental.AUTOTUNE)
# .map(lambda x: x)
.batch(1)
)
for x in dataset:
input("Press Enter to continue...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment