src.model.deeplearn.handle.transf_octorf_handler
Classes
|
- 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.TransfOctoRFPwiseClassifand 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 asDLTransferHandler(seeTORFTransferHandler).freeze_training (list or None) – Optional freeze-training specification (list of dicts). When given, training is driven by
DLFreezeTrainingExecutorso 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.nnwithout rebuilding it. Used bycompile()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_batchin a manual mini-batch loop instead ofmodel.predictto avoid the overhead of Keras’s internaltf.data.Dataset.from_tensors()copy, which increases the runtime per call for large arrays. Thepredict_on_batchpath uses the same compiled predict function asmodel.predict, so outputs are bitwise identical.The mini-batch size is controlled by
predict_inner_batch_sizein VL3DCFG (default 128), which is distinct frompredict_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_functionisNone, auto-selects based onpoint_wise_labels,num_classes, andclass_weight. When set, resolves the named loss and instantiates with class weights and/orfocusing_parameteras 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_ratewas given as a number,self.learning_rateis a float andself.lr_scheduleris None. Whenlearning_ratewas given as a dict,self.learning_rateis None andself.lr_schedulerholds the schedule spec.- Returns:
Float or Keras LR schedule.
- build_callbacks()
Assemble the list of Keras callbacks.
- Returns:
List of callback instances.