MCPcopy Create free account
hub / github.com/lingeringlight/START / __init__

Method __init__

data/samplers.py:179–197  ·  view source on GitHub ↗
(self, data_source, batch_size, n_ins)

Source from the content-addressed store, hash-verified

177 """
178
179 def __init__(self, data_source, batch_size, n_ins):
180 if batch_size < n_ins:
181 raise ValueError(
182 "batch_size={} must be no less "
183 "than n_ins={}".format(batch_size, n_ins)
184 )
185
186 self.data_source = data_source
187 self.batch_size = batch_size
188 self.n_ins = n_ins
189 self.ncls_per_batch = self.batch_size // self.n_ins
190 self.index_dic = defaultdict(list)
191 for index, item in enumerate(data_source):
192 self.index_dic[item.label].append(index)
193 self.labels = list(self.index_dic.keys())
194 assert len(self.labels) >= self.ncls_per_batch
195
196 # estimate number of images in an epoch
197 self.length = len(list(self.__iter__()))
198
199 def __iter__(self):
200 batch_idxs_dict = defaultdict(list)

Callers

nothing calls this directly

Calls 1

__iter__Method · 0.95

Tested by

no test coverage detected