Closed njellinas closed 4 weeks ago
You seem to have a very outdated example, I see now that I missed a few places to update in the docs.
Samplers don't support len() because of dynamic batch sizes in lhotse. In the general case, you can't know the exact number of iterations up-front.
I created this custom class and it works:
class SimpleCutSampler(lhotse.dataset.sampling.SimpleCutSampler):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def __len__(self):
return int(np.ceil(self.num_cuts / self.time_constraint.max_cuts))
I have prepared a dataset with Cuts as mentioned in the tutorial:
I want a batch_size=16 so I have defined the max_cuts argument. But, when I calculate for my training loop the total number of iterations as
len(trainloader)
, I get the errorTypeError: object of type 'SimpleCutSampler' has no len()
. When I define my own samplers without lhotse there is always a method len that calculates the total number of batches, is this not implemented here?