keras-team/keras · error · NotImplementedError
`filepaths` property method has not been implemented in {}.
Error message
`filepaths` property method has not been implemented in {}. What it means
The base Iterator class declares filepaths as an abstract property; only DirectoryIterator (and iterators backed by files) implement it. Accessing it on an iterator that has no notion of files (e.g. NumpyArrayIterator) raises NotImplementedError by design.
Source
Thrown at keras/src/legacy/preprocessing/image.py:374
(len(batch_x), len(self.class_indices)), dtype=self.dtype
)
for i, n_observation in enumerate(index_array):
batch_y[i, self.classes[n_observation]] = 1.0
elif self.class_mode == "multi_output":
batch_y = [output[index_array] for output in self.labels]
elif self.class_mode == "raw":
batch_y = self.labels[index_array]
else:
return batch_x
if self.sample_weight is None:
return batch_x, batch_y
else:
return batch_x, batch_y, self.sample_weight[index_array]
@property
def filepaths(self):
"""List of absolute paths to image files."""
raise NotImplementedError(
"`filepaths` property method has not "
"been implemented in {}.".format(type(self).__name__)
)
@property
def labels(self):
"""Class labels of every observation."""
raise NotImplementedError(
"`labels` property method has not been implemented in {}.".format(
type(self).__name__
)
)
@property
def sample_weight(self):
raise NotImplementedError(
"`sample_weight` property method has not "
"been implemented in {}.".format(type(self).__name__)View on GitHub (pinned to 7a34a03db6)
Solutions
- Use flow_from_directory(...) instead of flow(...) when you need file paths
- Guard access with try/except NotImplementedError before reading the property
- In custom Iterator subclasses, override filepaths to return the source paths
Example fix
# before
paths = iterator.filepaths # raises on NumpyArrayIterator
# after
try:
paths = iterator.filepaths
except NotImplementedError:
paths = None Defensive patterns
Strategy: try-catch
Validate before calling
paths = iterator.filepaths if type(iterator).__name__ == 'DirectoryIterator' else None
Type guard
def has_filepaths(it):
try:
it.filepaths
return True
except NotImplementedError:
return False Try / catch
try:
paths = iterator.filepaths
except NotImplementedError:
paths = None # in-memory data has no files Prevention
- Feature-detect before introspecting iterators
- Prefer DirectoryIterator when tooling needs image paths
When it happens
Trigger: Calling iterator.filepaths on the result of flow(x, y) (NumpyArrayIterator), or on a custom Iterator subclass that did not override the property.
Common situations: Generic code that introspects iterators (Grad-CAM explainability tools, error-analysis scripts) run against in-memory numpy data instead of a directory dataset.
Related errors
- `labels` property method has not been implemented in {}.
- `sample_weight` property method has not been implemented in
- The TFSMLayer is only currently supported with the TensorFlo
- Unknown activation function '{activation}' cannot be seriali
- Could not interpret activation function identifier: {identif
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/5e5de345e0e57d00.
Report an issue: GitHub.