def test_fromlist(self):
        nb_points = 100
        pos = torch.randn((nb_points, 3))
        y = torch.tensor([range(10) for i in range(pos.shape[0])],
                         dtype=torch.float)
        d = Data(pos=pos, y=y)

        b = SimpleBatch.from_data_list([d, d])
        self.assertEqual(b.pos.size(), (2, 100, 3))
        self.assertEqual(b.y.size(), (2, 100, 10))
예제 #2
0
    def _get_collate_function(conv_type, is_multiscale):
        if is_multiscale:
            if conv_type.lower() == ConvolutionFormat.PARTIAL_DENSE.value.lower():
                return lambda datalist: MultiScaleBatch.from_data_list(datalist)
            else:
                raise NotImplementedError(
                    "MultiscaleTransform is activated and supported only for partial_dense format"
                )

        is_dense = ConvolutionFormatFactory.check_is_dense_format(conv_type)
        if is_dense:
            return lambda datalist: SimpleBatch.from_data_list(datalist)
        else:
            return lambda datalist: torch_geometric.data.batch.Batch.from_data_list(datalist)
예제 #3
0
 def __getitem__(self, index):
     return SimpleBatch.from_data_list(self.datalist)
print(data)
#Batch(batch=[1000], pos=[1000, 3], x=[1000, 3])

pointnet = PointNet(OmegaConf.create({'conv_type': 'PARTIAL_DENSE'}))

pointnet.set_input(data, "cpu")
data_out = pointnet.forward()
print(data_out.shape)
# torch.Size([1000, 4])

##################### DENSE FORMAT #####################

num_points = 500
num_classes = 10
input_nc = 3

pos = torch.randn((num_points, 3))
x = torch.randn((num_points, input_nc))

data = Data(pos=pos, x=x)
data = SimpleBatch.from_data_list([data, data])

print(data)
#SimpleBatch(pos=[2, 500, 3], x=[2, 500, 3])

pointnet = PointNet(OmegaConf.create({'conv_type': 'DENSE'}))

pointnet.set_input(data, "cpu")
data_out = pointnet.forward()
print(data_out.shape)
#torch.Size([2, 500, 4])