MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / get_sampler_by_name

Function get_sampler_by_name

datasets/data_utils.py:69–82  ·  view source on GitHub ↗

get sampler in torch.utils.data.sampler by name

(name)

Source from the content-addressed store, hash-verified

67
68
69def 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
85def get_data_loader(dset,

Callers 1

get_data_loaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected