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

Class RemoveRandomPoints

dataloader/data_augmentation.py:230–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228
229
230class RemoveRandomPoints:
231 def __init__(self, r):
232 if type(r) is list or type(r) is tuple:
233 assert len(r) == 2
234 assert 0 <= r[0] <= 1
235 assert 0 <= r[1] <= 1
236 self.r_min = float(r[0])
237 self.r_max = float(r[1])
238 else:
239 assert 0 <= r <= 1
240 self.r_min = None
241 self.r_max = float(r)
242
243 def __call__(self, e):
244 n = len(e)
245 if self.r_min is None:
246 r = self.r_max
247 else:
248 # Randomly select removal ratio
249 r = random.uniform(self.r_min, self.r_max)
250
251 mask = np.random.choice(range(n), size=int(n*r), replace=False) # select elements to remove
252 e[mask] = torch.zeros_like(e[mask])
253 return e
254
255
256class RemoveRandomBlock:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected