def test_quantize(self): data_random = Data(pos=torch.randn(100, 3) * 0.1, x=torch.ones((100, 1))) gr = cT.GridSampling(0.2, quantize_coords=True) quantized = gr(data_random) self.assertEqual(quantized.x.shape[0], quantized.pos.shape[0]) self.assertEqual(quantized.num_nodes, quantized.pos.shape[0]) self.assertEqual(quantized.pos.dtype, torch.int)
def test_double_grid_sampling(self): data_random = Data(pos=torch.randn(1000, 3) * 0.1, x=torch.ones((1000, 1))) data_fragment = torch.load( os.path.join(DIR_PATH, "test_data/fragment_000003.pt")) sparse = cT.ToSparseInput(0.02) gr = cT.GridSampling(0.02) self.loop(data_random, gr, sparse, "random") self.loop(data_fragment, gr, sparse, "fragment")
def setUp(self): self.sampler = cT.GridSampling(0.04) num_points = 5 pos = torch.from_numpy( np.array([[0, 0, 0.01], [0.01, 0, 0], [0, 0.01, 0], [0, 0.01, 0], [0.01, 0, 0.01]])) batch = torch.from_numpy(np.zeros(num_points)).long() y = np.asarray(np.random.randint(0, 2, 5)) uniq, counts = np.unique(y, return_counts=True) self.answer = uniq[np.argmax(counts)] y = torch.from_numpy(y) self.data = Data(pos=pos, batch=batch, y=y)
def __init__(self, root, sample_per_epoch=100, radius=2, *args, **kwargs): self._sample_per_epoch = sample_per_epoch self._radius = radius self._grid_sphere_sampling = cT.GridSampling(size=radius / 10.0) super().__init__(root, *args, **kwargs)