Skip to content

ensemble

Prediction reducers for ensemble / TTA / voting workflows.

Pure callables on a sequence of per-point prediction tensors. They aggregate without knowing how the predictions were produced (live inference, saved files, multi-model fold ensemble, multi-seed voting). Each reducer ships as a function (call inline) and a class (instantiate when chosen by config).

Classes:

  • Ensemble –

    Base class for the class form of a prediction reducer.

  • MeanEnsemble –

    Class form of mean_ensemble.

  • VoteEnsemble –

    Class form of vote_ensemble.

Functions:

  • mean_ensemble –

    Per-point mean across a list of prediction tensors.

  • vote_ensemble –

    Per-point majority-vote counts across a list of prediction tensors.

Ensemble

Ensemble()

Base class for the class form of a prediction reducer.

Subclasses implement forward to aggregate a sequence of per-point prediction tensors into one.

MeanEnsemble

MeanEnsemble()

Bases: Ensemble

Class form of mean_ensemble.

Stateless wrapper for use when the reducer is chosen by config or stored as part of a pipeline.

Example
from torch_pointcloud.utils.ensemble import MeanEnsemble

reducer = MeanEnsemble()
probs = reducer(outputs)

VoteEnsemble

VoteEnsemble(num_classes: int)

Bases: Ensemble

Class form of vote_ensemble.

Parameters:

  • num_classes (int) –

    Channel count for the one-hot encoding. Stored on the instance so forward matches the Callable[[Sequence[Tensor]], Tensor] signature of MeanEnsemble.

Example
from torch_pointcloud.utils.ensemble import VoteEnsemble

reducer = VoteEnsemble(num_classes=13)
votes = reducer(outputs)
labels = votes.argmax(dim=-1)

mean_ensemble

mean_ensemble(outputs: Sequence[Tensor]) -> Tensor

Per-point mean across a list of prediction tensors.

Parameters:

  • outputs (Sequence[Tensor]) –

    Sequence of \((N, C)\) tensors (typically softmax probabilities or logits). All must have the same shape.

Returns:

  • Tensor –

    Mean along the stacking dim, shape \((N, C)\).

vote_ensemble

vote_ensemble(
    outputs: Sequence[Tensor], num_classes: int
) -> Tensor

Per-point majority-vote counts across a list of prediction tensors.

Each output is argmax'd along its last dim, one-hot encoded with num_classes channels, and summed across the ensemble. Take argmax of the result to get the majority-vote labels per point; the raw counts are useful for tie inspection.

Parameters:

  • outputs (Sequence[Tensor]) –

    Sequence of \((N, C)\) tensors. The argmax of each is taken, so either logits or probabilities work.

  • num_classes (int) –

    Channel count \(C\) used for the one-hot encoding. Must be at least max(argmax(output)) + 1; pass the model's num_classes.

Returns:

  • Tensor –

    Per-point class-vote counts, shape \((N, \text{num\_classes})\), dtype

  • Tensor –

    matching the inputs.