Table of Contents

Class PointNetPlusPlus<T>

Namespace
AiDotNet.PointCloud.Models
Assembly
AiDotNet.dll

Implements the PointNet++ architecture for hierarchical point cloud processing.

public class PointNetPlusPlus<T> : NeuralNetworkBase<T>, INeuralNetworkModel<T>, IInterpretableModel<T>, IInputGradientComputable<T>, IDisposable, IPointCloudClassification<T>, IPointCloudSegmentation<T>, IPointCloudModel<T>, INeuralNetwork<T>, IFullModel<T, Tensor<T>, Tensor<T>>, IModel<Tensor<T>, Tensor<T>, ModelMetadata<T>>, IModelSerializer, ICheckpointableModel, IParameterizable<T, Tensor<T>, Tensor<T>>, IFeatureAware, IFeatureImportance<T>, ICloneable<IFullModel<T, Tensor<T>, Tensor<T>>>, IGradientComputable<T, Tensor<T>, Tensor<T>>, IJitCompilable<T>

Type Parameters

T

The numeric type used for calculations (e.g., float, double).

Inheritance
PointNetPlusPlus<T>
Implements
IFullModel<T, Tensor<T>, Tensor<T>>
IModel<Tensor<T>, Tensor<T>, ModelMetadata<T>>
IParameterizable<T, Tensor<T>, Tensor<T>>
ICloneable<IFullModel<T, Tensor<T>, Tensor<T>>>
IGradientComputable<T, Tensor<T>, Tensor<T>>
Inherited Members
Extension Methods

Remarks

For Beginners: PointNet++ extends PointNet by adding hierarchical feature learning at multiple scales.

Key improvements over PointNet: - Hierarchical structure: Processes point clouds at multiple resolutions - Local context: Captures fine-grained local patterns - Multi-scale grouping: Learns features at different scales simultaneously - Better generalization: More robust to non-uniform point density

Architecture components: 1. Set Abstraction Layers: Hierarchically group points and extract features - Sampling: Select subset of points as centroids - Grouping: Find neighboring points around each centroid - PointNet layer: Extract features from each local region 2. Feature Propagation Layers: Upsample features for segmentation tasks - Interpolation: Propagate features from coarse to fine levels - Skip connections: Combine with features from encoder

Why hierarchical learning matters: - Different patterns exist at different scales (like edges vs. shapes in images) - Local context provides detailed geometry information - Global context provides overall shape understanding - Combining both gives comprehensive understanding

Applications: - Fine-grained classification - Part segmentation (identifying specific parts of objects) - Semantic segmentation (labeling each point) - Better performance on complex, detailed shapes

Example use case - autonomous driving: - Coarse level: Identify general object shapes (car, pedestrian) - Medium level: Recognize object parts (wheels, windows) - Fine level: Detect details (door handles, mirrors)

Reference: "PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric Space" by Qi et al., NeurIPS 2017

Constructors

PointNetPlusPlus()

Initializes a new instance of the PointNetPlusPlus class with default options.

public PointNetPlusPlus()

PointNetPlusPlus(PointNetPlusPlusOptions, ILossFunction<T>?)

Initializes a new instance of the PointNetPlusPlus class with configurable options.

public PointNetPlusPlus(PointNetPlusPlusOptions options, ILossFunction<T>? lossFunction = null)

Parameters

options PointNetPlusPlusOptions

Configuration options for the PointNet++ model.

lossFunction ILossFunction<T>

Optional loss function for training.

PointNetPlusPlus(int, int[], double[], int[][], bool, ILossFunction<T>?)

Initializes a new instance of the PointNetPlusPlus class.

public PointNetPlusPlus(int numClasses, int[] samplingRates, double[] searchRadii, int[][] mlpDimensions, bool useMultiScaleGrouping = false, ILossFunction<T>? lossFunction = null)

Parameters

numClasses int

Number of output classes.

samplingRates int[]

Number of points to sample at each hierarchy level.

searchRadii double[]

Search radius for finding neighbors at each level.

mlpDimensions int[][]

MLP layer dimensions for each set abstraction level.

useMultiScaleGrouping bool

Whether to use multi-scale grouping (MSG).

lossFunction ILossFunction<T>

Optional loss function for training.

Remarks

For Beginners: Creates a PointNet++ model with hierarchical feature learning.

Parameters explained:

  • numClasses: How many categories to classify into
  • samplingRates: How many points to keep at each level Example: [512, 128, 32] means:
    • Level 1: Sample 512 points from input
    • Level 2: Sample 128 points from the 512
    • Level 3: Sample 32 points from the 128
  • searchRadii: How far to look for neighbors at each level Example: [0.1, 0.2, 0.4] means:
    • Level 1: Look 0.1 units around each point
    • Level 2: Look 0.2 units (larger neighborhood)
    • Level 3: Look 0.4 units (even larger)
  • mlpDimensions: Feature dimensions for processing at each level Example: [[64,64,128], [128,128,256], [256,512,1024]]
  • useMultiScaleGrouping: Process each level at multiple scales (more robust but slower)

Example configuration for ModelNet40:

  • samplingRates: [512, 128, null] (null means use all remaining points)
  • searchRadii: [0.2, 0.4, null]
  • mlpDimensions: [[64,64,128], [128,128,256], [256,512,1024]]

Properties

SupportsTraining

Indicates whether this network supports training (learning from data).

public override bool SupportsTraining { get; }

Property Value

bool

Remarks

For Beginners: Not all neural networks can learn. Some are designed only for making predictions with pre-set parameters. This property tells you if the network can learn from data.

Methods

Backpropagate(Tensor<T>)

Performs backpropagation to compute gradients for network parameters.

public override Tensor<T> Backpropagate(Tensor<T> outputGradient)

Parameters

outputGradient Tensor<T>

Returns

Tensor<T>

The gradients of the loss with respect to the network inputs.

Remarks

For Beginners: Backpropagation is how neural networks learn. After making a prediction, the network calculates how wrong it was (the error). Then it works backward through the layers to figure out how each parameter contributed to that error. This method handles that backward flow of information.

The "gradients" are numbers that tell us how to adjust each parameter to reduce the error.

API Change Note: The signature changed from Vector<T> to Tensor<T> to support multi-dimensional gradients. This is a breaking change. If you need backward compatibility, consider adding an overload that accepts Vector<T> and converts it internally to Tensor<T>.

Exceptions

InvalidOperationException

Thrown when the network is not in training mode or doesn't support training.

ClassifyPointCloud(Tensor<T>)

Classifies a point cloud into one of the predefined categories.

public Vector<T> ClassifyPointCloud(Tensor<T> pointCloud)

Parameters

pointCloud Tensor<T>

Input point cloud tensor of shape [N, 3+F].

Returns

Vector<T>

A vector of class probabilities of length C, where C is the number of classes.

Remarks

For Beginners: This method determines what object the point cloud represents.

The classification process:

  • Takes the entire point cloud as input
  • Processes all points together to understand the overall shape
  • Returns probabilities for each possible category

Example with furniture classification:

  • Input: Point cloud of a furniture piece
  • Output: [0.85 chair, 0.10 stool, 0.03 table, 0.02 bench]
  • The model predicts it's most likely a chair (85% confidence)

The returned probabilities sum to 1.0, allowing you to:

  • Pick the most likely category (highest probability)
  • Understand the model's confidence in its prediction
  • Consider alternative possibilities if the top prediction has low confidence

CreateNewInstance()

Creates a new instance of the same type as this neural network.

protected override IFullModel<T, Tensor<T>, Tensor<T>> CreateNewInstance()

Returns

IFullModel<T, Tensor<T>, Tensor<T>>

A new instance of the same neural network type.

Remarks

For Beginners: This creates a blank version of the same type of neural network.

It's used internally by methods like DeepCopy and Clone to create the right type of network before copying the data into it.

DeserializeNetworkSpecificData(BinaryReader)

Deserializes network-specific data that was not covered by the general deserialization process.

protected override void DeserializeNetworkSpecificData(BinaryReader reader)

Parameters

reader BinaryReader

The BinaryReader to read the data from.

Remarks

This method is called at the end of the general deserialization process to allow derived classes to read any additional data specific to their implementation.

For Beginners: Continuing the suitcase analogy, this is like unpacking that special compartment. After the main deserialization method has unpacked the common items (layers, parameters), this method allows each specific type of neural network to unpack its own unique items that were stored during serialization.

ExtractGlobalFeatures(Tensor<T>)

Extracts global features from a point cloud.

public Vector<T> ExtractGlobalFeatures(Tensor<T> pointCloud)

Parameters

pointCloud Tensor<T>

Input point cloud tensor of shape [N, 3+F] where N is number of points, and 3+F represents XYZ coordinates plus F additional features.

Returns

Vector<T>

A feature vector representing the global characteristics of the point cloud.

Remarks

For Beginners: This method extracts a compact representation of the entire point cloud.

It's like creating a summary or "fingerprint" of the 3D object:

  • Input: Many individual 3D points (could be thousands or millions)
  • Output: A single feature vector that captures the essential characteristics
  • This summary can be used for classification, detection, or comparison

For example, extracting global features from point clouds of chairs would produce similar feature vectors for all chairs, despite differences in specific details.

ExtractPointFeatures(Tensor<T>)

Extracts per-point features from a point cloud.

public Tensor<T> ExtractPointFeatures(Tensor<T> pointCloud)

Parameters

pointCloud Tensor<T>

Input point cloud tensor of shape [N, 3+F].

Returns

Tensor<T>

A tensor of shape [N, D] where D is the feature dimension for each point.

Remarks

For Beginners: This method extracts features for each individual point.

Unlike global features which summarize the entire cloud, per-point features describe each point:

  • Input: N points with XYZ coordinates
  • Output: N feature vectors, one for each point
  • Each feature vector captures local and contextual information about that point

This is useful for tasks like:

  • Point cloud segmentation (labeling each point)
  • Finding specific features or parts in the 3D data
  • Understanding the local geometry around each point

ForwardWithMemory(Tensor<T>)

Performs a forward pass through the network while storing intermediate values for backpropagation.

public override Tensor<T> ForwardWithMemory(Tensor<T> input)

Parameters

input Tensor<T>

The input data to the network.

Returns

Tensor<T>

The output of the network.

Remarks

For Beginners: This method passes data through the network from input to output, but also remembers all the intermediate values. This is necessary for the learning process, as the network needs to know these values when figuring out how to improve.

API Change Note: The signature changed from Vector<T> to Tensor<T> to support multi-dimensional inputs. This is a breaking change. For backward compatibility, consider adding an overload that accepts Vector<T> and converts it internally to Tensor<T>.

Exceptions

InvalidOperationException

Thrown when the network doesn't support training.

GetModelMetadata()

Gets the metadata for this neural network model.

public override ModelMetadata<T> GetModelMetadata()

Returns

ModelMetadata<T>

A ModelMetaData object containing information about the model.

InitializeLayers()

Initializes the layers of the neural network based on the architecture.

protected override void InitializeLayers()

Remarks

For Beginners: This method sets up all the layers in your neural network according to the architecture you've defined. It's like assembling the parts of your network before you can use it.

Predict(Tensor<T>)

Makes a prediction using the neural network.

public override Tensor<T> Predict(Tensor<T> input)

Parameters

input Tensor<T>

The input data to process.

Returns

Tensor<T>

The network's prediction.

Remarks

For Beginners: This is the main method you'll use to get results from your trained neural network. You provide some input data (like an image or text), and the network processes it through all its layers to produce an output (like a classification or prediction).

SegmentPointCloud(Tensor<T>)

Performs semantic segmentation on a point cloud.

public Tensor<T> SegmentPointCloud(Tensor<T> pointCloud)

Parameters

pointCloud Tensor<T>

Input point cloud tensor of shape [N, 3+F].

Returns

Tensor<T>

A tensor of shape [N, C] containing class probabilities for each point, where C is the number of classes.

Remarks

For Beginners: This method assigns a category label to each point.

For each point, it predicts which category it belongs to:

  • Input: Point cloud with N points
  • Output: For each point, probabilities for each possible category
  • The category with highest probability is the predicted label

Example for indoor scene segmentation:

  • Categories might be: floor, wall, ceiling, furniture, etc.
  • Each point gets probabilities: [0.01 floor, 0.95 wall, 0.02 ceiling, 0.02 furniture]
  • The point would be labeled as "wall" (highest probability)

SerializeNetworkSpecificData(BinaryWriter)

Serializes network-specific data that is not covered by the general serialization process.

protected override void SerializeNetworkSpecificData(BinaryWriter writer)

Parameters

writer BinaryWriter

The BinaryWriter to write the data to.

Remarks

This method is called at the end of the general serialization process to allow derived classes to write any additional data specific to their implementation.

For Beginners: Think of this as packing a special compartment in your suitcase. While the main serialization method packs the common items (layers, parameters), this method allows each specific type of neural network to pack its own unique items that other networks might not have.

Train(Tensor<T>, Tensor<T>)

Trains the neural network on a single input-output pair.

public override void Train(Tensor<T> input, Tensor<T> expectedOutput)

Parameters

input Tensor<T>

The input data.

expectedOutput Tensor<T>

The expected output for the given input.

Remarks

This method performs one training step on the neural network using the provided input and expected output. It updates the network's parameters to reduce the error between the network's prediction and the expected output.

For Beginners: This is how your neural network learns. You provide: - An input (what the network should process) - The expected output (what the correct answer should be)

The network then:

  1. Makes a prediction based on the input
  2. Compares its prediction to the expected output
  3. Calculates how wrong it was (the loss)
  4. Adjusts its internal values to do better next time

After training, you can get the loss value using the GetLastLoss() method to see how well the network is learning.

UpdateParameters(Vector<T>)

Updates the network's parameters with new values.

public override void UpdateParameters(Vector<T> parameters)

Parameters

parameters Vector<T>

The new parameter values to set.

Remarks

For Beginners: During training, a neural network's internal values (parameters) get adjusted to improve its performance. This method allows you to update all those values at once by providing a complete set of new parameters.

This is typically used by optimization algorithms that calculate better parameter values based on training data.