Skip to content

HierarchicalSampler is not passed as a batch_sampler parameter #749

@ManuelZ

Description

@ManuelZ

I'm trying to use the MetricLossOnly trainer with the HierarchicalSampler, but it's inheriting from Sampler instead of from BatchSampler and due to this, the following block isn't executed.

if isinstance(sampler, torch.utils.data.BatchSampler):
return torch.utils.data.DataLoader(
dataset,
batch_sampler=sampler,
num_workers=num_workers,
collate_fn=collate_fn,
pin_memory=False,
)

And the training doesn't work because instead of getting a 4D tensor like b,c,h,w, I get b,b,c,h,w and an error.

I haven't digged further, but so far, the training seems to be working if I force the HierarchicalSampler to inherit from BatchSampler.

Why did you change it from BatchSampler to Sampler?

Thanks for this fantastic library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions