{"record":{"id":"5e5de345e0e57d00","repo":"keras-team/keras","slug":"filepaths-property-method-has-not-been-implement","errorCode":null,"errorMessage":"`filepaths` property method has not been implemented in {}.","messagePattern":"`filepaths` property method has not been implemented in (.+?)\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"keras/src/legacy/preprocessing/image.py","lineNumber":374,"sourceCode":"                (len(batch_x), len(self.class_indices)), dtype=self.dtype\n            )\n            for i, n_observation in enumerate(index_array):\n                batch_y[i, self.classes[n_observation]] = 1.0\n        elif self.class_mode == \"multi_output\":\n            batch_y = [output[index_array] for output in self.labels]\n        elif self.class_mode == \"raw\":\n            batch_y = self.labels[index_array]\n        else:\n            return batch_x\n        if self.sample_weight is None:\n            return batch_x, batch_y\n        else:\n            return batch_x, batch_y, self.sample_weight[index_array]\n\n    @property\n    def filepaths(self):\n        \"\"\"List of absolute paths to image files.\"\"\"\n        raise NotImplementedError(\n            \"`filepaths` property method has not \"\n            \"been implemented in {}.\".format(type(self).__name__)\n        )\n\n    @property\n    def labels(self):\n        \"\"\"Class labels of every observation.\"\"\"\n        raise NotImplementedError(\n            \"`labels` property method has not been implemented in {}.\".format(\n                type(self).__name__\n            )\n        )\n\n    @property\n    def sample_weight(self):\n        raise NotImplementedError(\n            \"`sample_weight` property method has not \"\n            \"been implemented in {}.\".format(type(self).__name__)","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/legacy/preprocessing/image.py#L356-L392","documentation":"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.","triggerScenarios":"Calling iterator.filepaths on the result of flow(x, y) (NumpyArrayIterator), or on a custom Iterator subclass that did not override the property.","commonSituations":"Generic code that introspects iterators (Grad-CAM explainability tools, error-analysis scripts) run against in-memory numpy data instead of a directory dataset.","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"],"exampleFix":"# before\npaths = iterator.filepaths  # raises on NumpyArrayIterator\n\n# after\ntry:\n    paths = iterator.filepaths\nexcept NotImplementedError:\n    paths = None","handlingStrategy":"try-catch","validationCode":"paths = iterator.filepaths if type(iterator).__name__ == 'DirectoryIterator' else None","typeGuard":"def has_filepaths(it):\n    try:\n        it.filepaths\n        return True\n    except NotImplementedError:\n        return False","tryCatchPattern":"try:\n    paths = iterator.filepaths\nexcept NotImplementedError:\n    paths = None  # in-memory data has no files","preventionTips":["Feature-detect before introspecting iterators","Prefer DirectoryIterator when tooling needs image paths"],"tags":["keras","iterator","not-implemented","abstract-method"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}