示例#1
0
    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.GridSampling3D(0.02, quantize_coords=True)
        gr = cT.GridSampling3D(0.02)

        self.loop(data_random, gr, gr, "random")
        self.loop(data_fragment, gr, sparse, "fragment")
 def test_quantize(self):
     data_random = Data(pos=torch.randn(100, 3) * 0.1, x=torch.ones((100, 1)))
     gr = cT.GridSampling3D(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 setUp(self):
     self.sampler = cT.GridSampling3D(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)
示例#4
0
 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.GridSampling3D(size=radius / 10.0)
     super().__init__(root, *args, **kwargs)