def slice(self): coords, colors, pcd = load_file("1.ply") voxel_size = 0.02 colors = torch.from_numpy(colors).float() bcoords = batched_coordinates([coords / voxel_size], dtype=torch.float32) tfield = TensorField(colors, bcoords) network = nn.Sequential( MinkowskiLinear(3, 16), MinkowskiBatchNorm(16), MinkowskiReLU(), MinkowskiLinear(16, 32), MinkowskiBatchNorm(32), MinkowskiReLU(), MinkowskiToSparseTensor(), MinkowskiConvolution(32, 64, kernel_size=3, stride=2, dimension=3), MinkowskiConvolutionTranspose(64, 32, kernel_size=3, stride=2, dimension=3), ) otensor = network(tfield) ofield = otensor.slice(tfield) self.assertEqual(len(tfield), len(ofield)) self.assertEqual(ofield.F.size(1), otensor.F.size(1)) ofield = otensor.cat_slice(tfield) self.assertEqual(len(tfield), len(ofield)) self.assertEqual(ofield.F.size(1), (otensor.F.size(1) + tfield.F.size(1)))
def test_network_device(self): coords, colors, pcd = load_file("1.ply") voxel_size = 0.02 colors = torch.from_numpy(colors) bcoords = batched_coordinates([coords / voxel_size]) tfield = TensorField(colors, bcoords, device=0).float() network = nn.Sequential( MinkowskiLinear(3, 16), MinkowskiBatchNorm(16), MinkowskiReLU(), MinkowskiLinear(16, 32), MinkowskiBatchNorm(32), MinkowskiReLU(), MinkowskiToSparseTensor(), MinkowskiConvolution(32, 64, kernel_size=3, stride=2, dimension=3), ).to(0) print(network(tfield))