I assume self.matX is a numpy array containing all samples in dim0.
If that’s the case, you might need to return len(self.matX) or self.matX.shape[0] in the __len__ function instead of the length of self.paths.
PS: you can post code snippets by wrapping them into three backticks ```, which makes your code easier to debug.