MCPcopy Create free account
hub / github.com/MetaSLAM/SphereVLAD / get_data

Method get_data

dataloader/triplet_dataloader.py:46–63  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

44 return q_tuple
45
46 def get_data(self):
47 q_tuple = []
48
49 while(1):
50 # if try data_count times still can not found a proper batch, resample
51 if self.data_count > (len(self.file_idxs)-self.config.TRAINING.BATCH.BATCH_SIZE):
52 self.shuffle_query()
53 continue
54 batch_keys = self.file_idxs[self.data_count]
55 # select the batch with qualified number of positives and negatives for training
56 if (len(self.queries[batch_keys]["positives"]) < self.config.TRAINING.BATCH.POSITIVES_PER_QUERY) or (len(self.queries[batch_keys]["negatives"]) < self.config.TRAINING.BATCH.NEGATIVES_PER_QUERY):
57 self.data_count+=1
58 continue
59 q_tuple = self.get_tuple(self.queries[batch_keys], hard_neg=[], other_neg=True)
60 self.data_count+=1
61 break
62
63 return q_tuple
64
65 def shuffle_query(self):
66 random.shuffle(self.file_idxs)

Callers 1

__getitem__Method · 0.95

Calls 2

shuffle_queryMethod · 0.95
get_tupleMethod · 0.95

Tested by

no test coverage detected