0

I'm using TensorFlow to load the MNIST dataset, and it keeps printing "Cleanup called..." on the output cell continuously.

enter image description here

And this also happens when I start the training.

I am using tf version 2.6.4

Code:

train_ds, test_ds = tfds.load(
    'mnist',
    split=['train', 'test'],
    as_supervised=True
)
def normalize_img(image, label):
    return tf.cast(image, tf.float32) / 255., label
train_ds = train_ds.map(normalize_img, num_parallel_calls=tf.data.AUTOTUNE)
train_ds = train_ds.shuffle(len(train_ds))
train_ds = train_ds.batch(128)
train_ds = train_ds.prefetch(tf.data.AUTOTUNE)
next(iter(train_ds))

Output:

Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
Cleanup called...
...

I've already looked at this and this question. But the only solution there is to downgrade TensorFlow, which I do not want to do.

How can I properly load the data so that this message never appears?

  • Are you in kaggle env? If so, there're pretty much nothing you can do except downgrade. [Check.](https://www.kaggle.com/competitions/google-universal-image-embedding/discussion/340586) – Innat Dec 02 '22 at 11:13
  • I fixed the problem by loading the MNIST array and then calling `tf.data.Dataset.from_tensor_slices` which hopefully worked. However, if I come across a larger dataset the next time, I won't be able to load it all in array, therefore I'll have to downgrade it, thanks for the suggestion. – Pritish Mishra Dec 04 '22 at 11:55

0 Answers0