src.model.deeplearn.handle.transf_octorf_handler

Classes

TransfOctoRFHandler(arch, **kwargs)

class src.model.deeplearn.handle.transf_octorf_handler.TransfOctoRFHandler(arch, **kwargs)
Author:

Alberto M. Esmoris Pena

Handler for the TransfOctoRF neural network stage. Wraps the src.model.deeplearn.arch.transf_octorf_pwise_classif.TransfOctoRFPwiseClassif and manages compile, fit, and predict operations.

Unlike SimpleDLModelHandler, this handler does NOT use receptive fields or the pre/post-processing pipeline. The model orchestrator (TransfOctoRFClassificationModel) handles all data preparation (octree, features, RF, neighbors) and passes ready-to-use tensors directly.

Variables:
  • training_epochs (int) – Number of training epochs.

  • batch_size (int) – Training batch size.

  • learning_rate (float) – Optimizer learning rate.

  • gradient_centralization (bool) – Enable post-update GC.

  • optimizer_name (str) – "adam" or "sgd".

  • momentum (float) – SGD momentum (ignored for Adam).

  • nesterov (bool) – Nesterov acceleration for SGD.

  • early_stopping (dict or None) – Early stopping config dict or None.

  • checkpoint_path (str or None) – Path to save best weights or None.

  • checkpoint_monitor (str) – Metric to monitor for checkpoint.

  • class_weight (list or str or None) – Class weights (list, "auto", or None).

  • lr_on_plateau (dict or None) – ReduceLROnPlateau config or None.

  • lr_scheduler (dict or None) – LR schedule config dict or None.

  • fit_verbose (int or str) – Verbosity for training (0, 1, 2, “auto”).

  • predict_verbose (int or str) – Verbosity for prediction.

  • summary_report_path (str or None) – Path to export the NN summary table.

  • transfer_handler (TORFTransferHandler) – Optional handler that transfers weights from a previously trained Keras model before training starts. Same JSON specification as DLTransferHandler (see TORFTransferHandler).

  • freeze_training (list or None) – Optional freeze-training specification (list of dicts). When given, training is driven by DLFreezeTrainingExecutor so layers can be frozen during configured epoch intervals exactly like for standard VL3D deep learning models.

__init__(arch, **kwargs)

Initialize a TransfOctoRFHandler.

Parameters:
  • arch – The TransfOctoRF architecture.

  • kwargs – Training configuration.

compile(X=None, y=None, y_rf=None, **kwargs)

Build and compile the Keras model.

compile_existing_nn()

Attach a fresh optimizer + loss + metrics to self.arch.nn without rebuilding it. Used by compile() after building the architecture and by the continue-training path to restore an optimizer that was cleared during pickle serialization.

predict(X, y=None, zout=None, plots_and_reports=True)

Run transformer prediction.

Uses predict_on_batch in a manual mini-batch loop instead of model.predict to avoid the overhead of Keras’s internal tf.data.Dataset.from_tensors() copy, which increases the runtime per call for large arrays. The predict_on_batch path uses the same compiled predict function as model.predict, so outputs are bitwise identical.

The mini-batch size is controlled by predict_inner_batch_size in VL3DCFG (default 128), which is distinct from predict_batch_size (which controls the outer CPU-side gather buffer).

Parameters:

X – List of [features, coordinates, mask].

Returns:

Predicted probabilities (B, n_c) or (B, 1).

export_summary_report()

Export the model summary to a text file and log it.

build_metrics()

Resolve metric name strings to Keras metric objects.

Delegates to DLModelCompiler.resolve_metrics() for consistent metric resolution across all handlers.

Returns:

List of Keras metric objects.

Return type:

list

build_loss(num_classes)

Build the loss function by name or auto-selection.

When loss_function is None, auto-selects based on point_wise_labels, num_classes, and class_weight. When set, resolves the named loss and instantiates with class weights and/or focusing_parameter as needed.

Parameters:

num_classes (int) – Number of output classes.

Returns:

Loss function or string.

resolve_class_weights()

Resolve class_weight to a list of floats or None.

Returns:

List of class weights or None.

build_optimizer()

Build the optimizer with optional LR schedule.

Returns:

Keras optimizer instance.

build_lr()

Build the learning rate (float or schedule).

When learning_rate was given as a number, self.learning_rate is a float and self.lr_scheduler is None. When learning_rate was given as a dict, self.learning_rate is None and self.lr_scheduler holds the schedule spec.

Returns:

Float or Keras LR schedule.

build_callbacks()

Assemble the list of Keras callbacks.

Returns:

List of callback instances.