TrainCTLearnModel#
- class ctlearn.tools.train_model.TrainCTLearnModel(*args: t.Any, **kwargs: t.Any)[source]#
Bases:
ToolBase tool to train a
~ctlearn.core.model.CTLearnModelon R1/DL1a data.The tool holds configurations and set up functions.
Attributes Summary
Size of the batch to train the neural network.
Early stopping parameters for the Keras callback or the PyTorch scheduler.
List of specific file pattern for matching files in
input_dir_backgroundList of specific file pattern for matching files in
input_dir_signalInput directory for background events
Input directory for signal events
Learning rate reducing parameters for the Keras callback or the PyTorch scheduler.
Model type to be used in the Keras or PyTorch framework.
Number of epochs to train the neural network.
Optimizer to use for training.
Output directory for the trained reconstructor.
Random seed for shuffling the data before the training/validation split and after the end of an epoch.
List of reconstruction tasks to perform.
Set whether to save the best validation checkpoint only.
Set whether to sort the telescope images by intensity in the data loader.
Set whether to stack the telescope images in the data loader.
Fraction of the data to use for validation
Methods Summary
finish()Perform final cleanup and save metadata after the core logic completes.
setup()Initialize the tool configuration, validate parameters, and setup data handlers.
This is an abstract method for the setup of the framework-specific training tool.
Write the provenance log and a second one in the output directory.
Attributes Documentation
- aliases = {'background': 'TrainCTLearnModel.input_dir_background', 'batch-size': 'TrainCTLearnModel.batch_size', 'n-epochs': 'TrainCTLearnModel.n_epochs', 'pattern-background': 'TrainCTLearnModel.file_pattern_background', 'pattern-signal': 'TrainCTLearnModel.file_pattern_signal', 'random-seed': 'TrainCTLearnModel.random_seed', 'reco': 'TrainCTLearnModel.reco_tasks', 'save-best-val': 'TrainCTLearnModel.save_best_validation_only', 'signal': 'TrainCTLearnModel.input_dir_signal', ('o', 'output'): 'TrainCTLearnModel.output_dir'}#
- batch_size#
Size of the batch to train the neural network.
- classes = [<class 'ctlearn.core.model.CTLearnModel'>, <class 'dl1_data_handler.reader.DLDataReader'>, <class 'dl1_data_handler.reader.DLImageReader'>, <class 'dl1_data_handler.reader.DLWaveformReader'>, <class 'dl1_data_handler.reader.DLFeatureVectorReader'>]#
- dl1dh_reader_type#
. Possible values: []
- early_stopping#
Early stopping parameters for the Keras callback or the PyTorch scheduler. E.g. {‘monitor’: ‘val_loss’, ‘patience’: 4, ‘verbose’: 1, ‘restore_best_weights’: True}.
- file_pattern_background#
List of specific file pattern for matching files in
input_dir_background
- file_pattern_signal#
List of specific file pattern for matching files in
input_dir_signal
- input_dir_background#
Input directory for background events
- input_dir_signal#
Input directory for signal events
- lr_reducing#
Learning rate reducing parameters for the Keras callback or the PyTorch scheduler. E.g. {‘factor’: 0.5, ‘patience’: 5, ‘min_delta’: 0.01, ‘min_lr’: 0.000001}.
- model_type#
Model type to be used in the Keras or PyTorch framework. The framework is determined by the inherited tools being used.
- n_epochs#
Number of epochs to train the neural network.
- optimizer#
Optimizer to use for training. E.g. {‘name’: ‘Adam’, ‘base_learning_rate’: 0.0001, ‘adam_epsilon’: 1.0e-8}.
- output_dir#
Output directory for the trained reconstructor.
- random_seed#
Random seed for shuffling the data before the training/validation split and after the end of an epoch.
- reco_tasks#
List of reconstruction tasks to perform. ‘type’: classification of the primary particle type; ‘energy’: regression of the primary particle energy; ‘cameradirection’: reconstruction of the primary particle arrival direction in camera coordinates; ‘skydirection’: reconstruction of the primary particle arrival direction in sky coordinates.
- save_best_validation_only#
Set whether to save the best validation checkpoint only.
- sort_by_intensity#
Set whether to sort the telescope images by intensity in the data loader. Requires DLDataReader mode to be
stereo.
- stack_telescope_images#
Set whether to stack the telescope images in the data loader. Requires DLDataReader mode to be
stereo.
- validation_split#
Fraction of the data to use for validation
Methods Documentation
- finish()[source]#
Perform final cleanup and save metadata after the core logic completes.
This method writes provenance data (such as configuration and execution context) to the output file, finalizes tables, and ensures all file handlers are safely closed.
- setup()[source]#
Initialize the tool configuration, validate parameters, and setup data handlers.
This method is the first part of the tool execution lifecycle. It validates input arguments, sets up the configuration dictionary, configures the output file, and prepares the DataReader to ensure everything is ready before the core processing begins.