get sampler in torch.utils.data.sampler by name
(name)
| 67 | |
| 68 | |
| 69 | def get_sampler_by_name(name): |
| 70 | ''' |
| 71 | get sampler in torch.utils.data.sampler by name |
| 72 | ''' |
| 73 | sampler_name_list = sorted(name for name in torch.utils.data.sampler.__dict__ |
| 74 | if not name.startswith('_') and callable(sampler.__dict__[name])) |
| 75 | try: |
| 76 | if name == 'DistributedSampler': |
| 77 | return torch.utils.data.distributed.DistributedSampler |
| 78 | else: |
| 79 | return getattr(torch.utils.data.sampler, name) |
| 80 | except Exception as e: |
| 81 | print(repr(e)) |
| 82 | print('[!] select sampler in:\t', sampler_name_list) |
| 83 | |
| 84 | |
| 85 | def get_data_loader(dset, |