From 191f2461c585de7edf6891c7c93089803d995dec Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 4 Aug 2020 21:24:33 -0700 Subject: [PATCH] [tfds] Fix tfds.as_numpy which now returns a reusable iterable. `next(ds)` -> `next(iter(ds))` Context: https://github.com/tensorflow/datasets/issues/2270 PiperOrigin-RevId: 324951455 --- tutorials/lm_dpsgd_tutorial.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/lm_dpsgd_tutorial.py b/tutorials/lm_dpsgd_tutorial.py index 93a8971..8f72ff6 100644 --- a/tutorials/lm_dpsgd_tutorial.py +++ b/tutorials/lm_dpsgd_tutorial.py @@ -139,8 +139,8 @@ def load_data(): test_dataset = tfds.load(name='lm1b/subwords8k', split=tfds.Split.TEST, batch_size=10000) - train_data = next(tfds.as_numpy(train_dataset)) - test_data = next(tfds.as_numpy(test_dataset)) + train_data = next(iter(tfds.as_numpy(train_dataset))) + test_data = next(iter(tfds.as_numpy(test_dataset))) train_data = train_data['text'].flatten() test_data = test_data['text'].flatten() else: