Skip to content

EpochIterator initialized with a generator cannot be reset #20402

@nicolaspi

Description

@nicolaspi

EpochIterator initialized with a generator cannot be reset, consequently the following bug might occur: #20394
Another consequence is running prediction on an unbuilt model discards samples:

import os
import numpy as np
os.environ["KERAS_BACKEND"] = "jax"
import keras

set_size = 4
def generator():
  for _ in range(set_size):
    yield np.ones((1, 4)), np.ones((1, 1))

model = keras.models.Sequential([keras.layers.Dense(1, activation="relu")])
model.compile(loss="mse", optimizer="adam")
y = model.predict(generator())

print(f"There should be {set_size} predictions, there are {len(y)}.")
There should be 4 predictions, there are 2.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions