Skip to content

Commit

Permalink
Workaround for pydataset hanging issue
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Nov 4, 2024
1 parent 192b7b2 commit c052cea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion keras/src/callbacks/tensorboard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def list_summaries(logdir):
class TestTensorBoardV2(testing.TestCase):
def _get_log_dirs(self):
logdir = os.path.join(
self.get_temp_dir(), str(random.randint(1, 1e7)), "tb"
self.get_temp_dir(), str(random.randint(1, int(1e7))), "tb"
)
train_dir = os.path.join(logdir, "train")
validation_dir = os.path.join(logdir, "validation")
Expand Down
2 changes: 1 addition & 1 deletion keras/src/models/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _maybe_warn_inputs_struct_mismatch(self, inputs):
model_inputs_struct = tree.map_structure(
lambda x: x.name, self._inputs_struct
)
inputs_struct = tree.map_structure(lambda x: "*", inputs)
inputs_struct = tree.map_structure(lambda x: f"type({x})", inputs)
warnings.warn(
"The structure of `inputs` doesn't match the expected "
f"structure: {model_inputs_struct}. "
Expand Down
8 changes: 6 additions & 2 deletions keras/src/trainers/data_adapters/py_dataset_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,11 @@ def get(self):
if inputs is not None:
yield inputs
except queue.Empty:
pass
warnings.warn(
"Generator ran out of batches before reaching `num_batches`"
)
self.stop()
return
except Exception as e:
self.stop(drain_queue_and_join=True)
raise e
Expand All @@ -653,7 +657,7 @@ def get(self):
# which may happen before the first `on_epoch_begin`. But it's not ok to
# poll after `on_epoch_end`.
raise ValueError(
"Iterator called after `on_epoch_end` and before `on_epoch_begin`."
"Iterator called after `on_epoch_end` or before `on_epoch_begin`."
)


Expand Down

0 comments on commit c052cea

Please sign in to comment.