Main Content


Train PointPillars object detector


Train a Detector

detector = trainPointPillarsObjectDetector(trainingData,detector,options) trains a PointPillars object detector using deep learning and the specified training options for the detection network.

[detector,info] = trainPointPillarsObjectDetector(trainingData,detector,options) returns information on the training progress of the object detector, such as the training accuracy for each iteration.

Resume Training a Detector

detector = trainPointPillarsObjectDetector(trainingData,checkpoint,options) resumes training from the saved detector checkpoint.

You can use this syntax to:

  • Add more training data and continue the training.

  • Improve training accuracy by increasing the maximum number of iterations.

Input Arguments

collapse all

Training data, specified as a valid datastore object or table.

  • If you use a datastore object, your data must be set up such that using the read function on the datastore object returns a cell array or table with three columns. Each row corresponds to a point cloud, and the columns must follow this format.

    • First column — Organized or unorganized point cloud data, specified as a pointCloud object.

    • Second column — Bounding boxes, specified as a cell array containing an M-by-9 matrix. Each row of the matrix is of the form [x y z width length height roll pitch yaw], representing the location and dimension of a bounding box. M is the number of bounding boxes.

    • Third column — Labels, specified as a cell array containing an M-by-1 categorical vector with object class names. All categorical data returned by the datastore must use the same pool of categories.

    You can use the combine function to combine two or more datastores. For more information on creating datastore objects, see the datastore function.

  • If you use a table, the table must have two or more columns. The first column must contain point cloud file names. The point cloud files can be in any format supported by pcread function. Each of the remaining columns represent a single object class such as Car, or Truck containing cell vectors. Each cell contains an M-by-9 matrix, M is the number of bounding boxes. The columns of the each matrix are of the form [x y z width length height roll pitch yaw], specifying the location and dimensions of the bounding box in the corresponding point cloud.

PointPillars object detector, specified as a pointPillarsObjectDetector object.

  • You can train an untrained object detector using the training options.

  • You can continue training a pretrained detector with additional training data, or perform more training iterations to improve detector accuracy.

Training options, specified as a TrainingOptionsSGDM, TrainingOptionsRMSProp, or TrainingOptionsADAM object returned by the trainingOptions (Deep Learning Toolbox) function. To specify the solver name and other options for network training, use the trainingOptions (Deep Learning Toolbox) function.


The trainPointPillarsObjectDetector function supports these training options.

Name-Value ArgumentsSupported Options
  • "auto", "gpu", "cpu"

  • For "multi-gpu", "parallel" set the DispatchInBackground argument to false.


Saved detector checkpoint, specified as a pointPillarsObjectDetector object. To save the detector after each epoch, specify the CheckpointPath name-value argument when creating your training options using the trainingOptions (Deep Learning Toolbox) function. Saving a checkpoint after each epoch is recommended because network training can take a few hours.

To load a checkpoint for a previously trained detector, first load the corresponding MAT file from the checkpoint path. Then extract the object detector from the loaded data. For example, if the CheckpointPath property of your options object is '/checkpath', you can load a checkpoint MAT file by using this code.

data = load("/checkpath/pointpillars_checkpoint__216__2018_11_16__13_34_30.mat");
checkpoint = data.detector;

The name of the MAT file includes the iteration number and timestamp of when the detector checkpoint was saved. The MAT file saves the detector in the detector variable. Use the trainPointPillarsObjectDetector function to train the detector.

pointPillarsDetector = trainPointPillarsObjectDetector(trainingData,checkpoint,options);

Output Arguments

collapse all

Trained PointPillars object detector, returned as pointPillarsObjectDetector object.

Training progress information, returned as a structure array with these fields. Each field corresponds to a stage of training.

  • TrainingLoss — Training loss at each iteration. The training loss is the mean squared error (MSE), calculated as the sum of the localization error, confidence loss, and classification loss.

  • ValidationLoss — Validation loss at each iteration.

Each field is a numeric vector with one element per training iteration. If the function does not calculate a value at a specific iteration, it returns a value of NaN for that iteration. The structure contains ValidationLoss only when options specifies validation data.

Introduced in R2021b