datamodule
Lightning datamodule wrapping point cloud datasets with the packed-batch collate.
Classes:
-
PointCloudDataModuleβLightningDataModule wrapping point cloud datasets with the packed-batch collate.
PointCloudDataModule [source] ΒΆ
PointCloudDataModule(
train_dataset: Optional[Dataset] = None,
val_dataset: Optional[Dataset] = None,
test_dataset: Optional[Dataset] = None,
*,
train_ratios: Optional[Sequence[int]] = None,
stack_keys: Optional[Sequence[str]] = None,
cat_keys: Optional[Sequence[str]] = None,
batch_size: int = 1,
eval_batch_size: Optional[int] = None,
num_workers: int = 0,
pin_memory: bool = False,
drop_last: bool = True,
timeout: float = 0.0,
prefetch_factor: Optional[int] = None,
persistent_workers: bool = False,
pin_memory_device: str = "",
)
Bases: LightningDataModule
LightningDataModule wrapping point cloud datasets with the packed-batch collate.
Each dataset is passed through as-is. To lengthen an epoch, wrap the training dataset with torch_pointcloud.datasets.RepeatDataset(dataset, k=...) before passing it in.
Loaders are built with torch_pointcloud.utils.data.PointCloudDataLoader, which collates to the packed-batch torch_pointcloud.utils.data.collate. Collation specs are never read off the dataset (transforms rewrite keys downstream); pass stack_keys / cat_keys to control how per-scene ground truth is batched (e.g. cat_keys=("box",) for a detection dataset). shuffle is forced to True for train and False for val/test. Without a val_dataset, val_dataloader returns an empty list so Trainer.fit runs train-only.
Parameters:
-
train_dataset(Optional[Dataset], default:None) βDataset for the training loop.
-
train_ratios(Optional[Sequence[int]], default:None) βOne positive integer sampling weight per child dataset of a
ConcatDatasettrain set. When set, the train loader draws single-dataset batches interleaved by these ratios viatorch_pointcloud.datasets.SingleDatasetBatchSampler, so every batch stays single-domain (required by per-dataset normalization such as PDNorm). LeaveNonefor a single dataset. -
val_dataset(Optional[Dataset], default:None) βDataset for the validation loop.
-
test_dataset(Optional[Dataset], default:None) βDataset for the test loop.
-
stack_keys(Optional[Sequence[str]], default:None) βKeys collated by stacking to a leading batch dim instead of concatenating.
-
cat_keys(Optional[Sequence[str]], default:None) βPacked keys that additionally emit a
batch_<key>per-element scene index. -
batch_size(int, default:1) βNumber of point clouds per batch.
-
eval_batch_size(Optional[int], default:None) βBatch size of the val/test loaders; defaults to
batch_size. Evaluation often runs full-resolution scenes while training runs crops, so the two memory envelopes differ (a benchmark protocol is typically one scene per batch). -
num_workers(int, default:0) βNumber of worker processes for data loading.
-
pin_memory(bool, default:False) βPin tensors in pinned (page-locked) memory before transfer.
-
drop_last(bool, default:True) βDrop the last incomplete batch. Applied to the train loader only; val/test always set
drop_last=False. -
timeout(float, default:0.0) βTimeout for collecting a batch from the workers.
-
prefetch_factor(Optional[int], default:None) βNumber of batches each worker prefetches ahead.
-
persistent_workers(bool, default:False) βKeep workers alive between epochs.
-
pin_memory_device(str, default:'') βTarget device for
pin_memory(e.g."cuda").
Methods:
-
setupβGraft the model's evaluation transform onto datasets that have none, and collate its inverse key.
-
configure_dataloaderβBuild a
PointCloudDataLoaderover the dataset with the module's collation and worker settings. -
train_dataloaderβBuild the shuffled train loader, drawing single-dataset batches when
train_ratiosis set. -
val_dataloaderβBuild the unshuffled validation loader, or an empty list when no validation set was given.
-
test_dataloaderβBuild the unshuffled test loader, falling back to the validation set when no test set was given.
setup [source] ΒΆ
Graft the model's evaluation transform onto datasets that have none, and collate its inverse key.
A segmentation module (LitSemanticSegmentationModel, LitPartSegmentationModel) with an inverse_key needs that key in cat_keys so multi-scene eval batches carry its batch_<key> scene index; it is added here. collate ignores cat_keys absent from the samples, so pipelines that write no inverse map are unaffected.
The LightningModule (built from the registry) carries its transform; an experiment leaves a dataset's transform as None to use it, or sets one explicitly for custom augmentation. A wrapper dataset (e.g. MixDataset) whose wrapped dataset already carries a transform is left alone: the recipe lives on the wrapped dataset and must not be applied a second time on its output. Wrappers that apply no transform of their own (RepeatDataset, ConcatDataset) are traversed so the transform lands on the wrapped datasets that actually run it.
configure_dataloader [source] ΒΆ
configure_dataloader(
dataset: Optional[Dataset],
*,
shuffle: bool,
drop_last: bool,
batch_size: Optional[int] = None,
sampler: Optional[Union[Sampler, Iterable]] = None,
batch_sampler: Optional[
Union[Sampler, Iterable]
] = None,
) -> DataLoader
Build a PointCloudDataLoader over the dataset with the module's collation and worker settings.
train_dataloader [source] ΒΆ
Build the shuffled train loader, drawing single-dataset batches when train_ratios is set.