Skip to content

Commit

Permalink
rename mergedTRN to stackedTRN
Browse files Browse the repository at this point in the history
also rename config parameter from concat_telescopes to stack_telescope_images
  • Loading branch information
Tjark Miener authored and Tjark Miener committed May 30, 2024
1 parent c311d89 commit 9702347
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 29 deletions.
10 changes: 5 additions & 5 deletions config/example_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

# List of reconstruction tasks. For now it's recommended to you single task learning.
# Valid options:
# - 'particletype'
# - 'type'
# - 'energy'
# - 'direction'
# These options have to be in consonance with the 'event_info' and
# 'transforms' in 'Data'.
# Requirements/recommendations:
# - 'particletype':
# - 'type':
# event_info:
# - 'true_shower_primary_id'
# transforms:
Expand Down Expand Up @@ -292,10 +292,10 @@ Input:
# Optional integer. Default: 1
batch_size_per_worker: 32

# Whether to concatenate the stereo images from an event to feed it
# Whether to stack the stereo images from an event to feed it
# to a monoscopic model.
# Optional boolean. Default: false
concat_telescopes: false
stack_telescope_images: false

# Settings for the TensorFlow model. The options in this and the
# Model Parameters section are passed to the Estimator model_fn
Expand Down Expand Up @@ -467,7 +467,7 @@ Model Parameters:
# For the classification task, the class names are passed into the dict
# in order of class label (0 to n-1).
standard_head:
particletype: {class_names: ['proton', 'gamma'], fc_head: [512, 256, 2], weight: 1.0}
type: {class_names: ['proton', 'gamma'], fc_head: [512, 256, 2], weight: 1.0}
energy: {fc_head: [512, 256, 1], weight: 1.0}
direction: {fc_head: [512, 256, 2], weight: 1.0}

Expand Down
6 changes: 3 additions & 3 deletions ctlearn/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(
mode="train",
class_names=None,
shuffle=True,
concat_telescopes=False,
stack_telescope_images=False,
):
"Initialization"
self.DL1DataReaderDL1DH = DL1DataReaderDL1DH
Expand All @@ -22,7 +22,7 @@ def __init__(
self.mode = mode
self.class_names = class_names
self.shuffle = shuffle
self.concat_telescopes = concat_telescopes
self.stack_telescope_images = stack_telescope_images
self.on_epoch_end()

# Decrypt the example description
Expand Down Expand Up @@ -93,7 +93,7 @@ def __init__(
self.img_shape[3],
)
# Reshape inputs into proper dimensions for the stereo analysis with merged models
if self.concat_telescopes:
if self.stack_telescope_images:
self.img_shape = (
self.img_shape[1],
self.img_shape[2],
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/CNNRNN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 16
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'CNNRNN'
backbone: {module: 'cnn_rnn', function: 'cnn_rnn_model'}
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/SingleCNN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 64
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'SingleCNN'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/TRN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 64
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'ThinResNet'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/calwaveSingleCNN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 8
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'SingleCNN'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/calwaveTRN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 8
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'ThinResNetWave'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/rawwaveSingleCNN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 8
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'SingleCNNWave'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/rawwaveTRN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 8
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'ThinResNetWave'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 64
concat_telescopes: true
stack_telescope_images: true
Model:
name: 'ThinResNet'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/triggerSingleCNN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 8
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'SingleCNN'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
2 changes: 1 addition & 1 deletion ctlearn/default_config_files/triggerTRN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Data:
'MAGICCam': 2
Input:
batch_size_per_worker: 8
concat_telescopes: false
stack_telescope_images: false
Model:
name: 'ThinResNetWave'
backbone: {module: 'single_cnn', function: 'single_cnn_model'}
Expand Down
12 changes: 6 additions & 6 deletions ctlearn/run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def run_model(config, mode="train", debug=False, log_to_file=False):
config["Input"] = {}
batch_size_per_worker = config["Input"].get("batch_size_per_worker", 64)
batch_size = batch_size_per_worker * strategy.num_replicas_in_sync
concat_telescopes = config["Input"].get("concat_telescopes", False)
stack_telescope_images = config["Input"].get("stack_telescope_images", False)

if mode == "train":
if "Training" not in config:
Expand All @@ -107,15 +107,15 @@ def run_model(config, mode="train", debug=False, log_to_file=False):
batch_size=batch_size,
mode=mode,
class_names=class_names,
concat_telescopes=concat_telescopes,
stack_telescope_images=stack_telescope_images,
)
validation_data = KerasBatchGenerator(
reader,
validation_indices,
batch_size=batch_size,
mode=mode,
class_names=class_names,
concat_telescopes=concat_telescopes,
stack_telescope_images=stack_telescope_images,
)
elif mode == "predict":
if "trigger_settings" in config["Data"]:
Expand All @@ -135,7 +135,7 @@ def run_model(config, mode="train", debug=False, log_to_file=False):
mode=mode,
class_names=class_names,
shuffle=False,
concat_telescopes=concat_telescopes,
stack_telescope_images=stack_telescope_images,
)

# Keras is only considering the last complete batch.
Expand All @@ -153,7 +153,7 @@ def run_model(config, mode="train", debug=False, log_to_file=False):
mode=mode,
class_names=class_names,
shuffle=False,
concat_telescopes=concat_telescopes,
stack_telescope_images=stack_telescope_images,
)

# Construct the model
Expand Down Expand Up @@ -475,7 +475,7 @@ def main():
parser.add_argument(
"--default_model",
"-d",
help="Default CTLearn Model; valid options: SingleCNN, TRN, rawwaveSingleCNN, rawwaveTRN, calwaveSingleCNN, calwaveTRN (mono), mergedTRN, and CNNRNN (stereo)",
help="Default CTLearn Model; valid options: SingleCNN, TRN, rawwaveSingleCNN, rawwaveTRN, calwaveSingleCNN, calwaveTRN (mono), stackedTRN, and CNNRNN (stereo)",
)
parser.add_argument(
"--clean",
Expand Down
4 changes: 2 additions & 2 deletions ctlearn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ def setup_DL1DataReader(config, mode):
event_info.append("true_energy")
transformations.append({"name": "MCEnergy"})

concat_telescopes = config["Input"].get("concat_telescopes", False)
if config["Data"]["mode"] == "stereo" and not concat_telescopes:
stack_telescope_images = config["Input"].get("stack_telescope_images", False)
if config["Data"]["mode"] == "stereo" and not stack_telescope_images:
for tel_desc in selected_telescope_types:
transformations.append(
{
Expand Down
6 changes: 3 additions & 3 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Pre-processing is performed using the DL1DataHandler Transform class.
Input
~~~~~

Set parameters of the KerasBatchGenerator that converts the loaded, processed data into generator of batches for the Keras application. Stereoscopic images can be concatenated via the ``concat_telescopes`` flag.
Set parameters of the KerasBatchGenerator that converts the loaded, processed data into generator of batches for the Keras application. Stereoscopic images can be stacked via the ``stack_telescope_images`` flag.

Model
~~~~~
Expand All @@ -40,7 +40,7 @@ CTLearn works with any TensorFlow-Keras model obeying the signature of a backbon

To use a custom model, provide in this section the directory containing a Python file that implements the model and the module name (that is, the file name minus the .py extension) and name of the model function within the module.

In addition, CTLearn includes two main models for gamma/hadron classification, energy and arrival direction regression. ``SingleCNN`` analyzes single telescope images using a convolutional neural network (CNN) or multiple residual blocks of convolutional layers (ResNet). Stereoscopic images can be concatenated beforehand (in the ``Input`` config section) to be analyzed by the ``SingleCNN`` model. ``CNN-RNN`` performs array-level reconstruction by feeding the output of a CNN or a ResNet for each telescope into either a recurrent neural network (RNN). All models are built on generic functions from ``basic.py`` and ``resnet_engine.py``. In addition, three different attention mechanisms are implemented in ``attention.py``.
In addition, CTLearn includes two main models for gamma/hadron classification, energy and arrival direction regression. ``SingleCNN`` analyzes single telescope images using a convolutional neural network (CNN) or multiple residual blocks of convolutional layers (ResNet). Stereoscopic images can be stacked beforehand (in the ``Input`` config section) to be analyzed by the ``SingleCNN`` model. ``CNN-RNN`` performs array-level reconstruction by feeding the output of a CNN or a ResNet for each telescope into either a recurrent neural network (RNN). All models are built on generic functions from ``basic.py`` and ``resnet_engine.py``. In addition, three different attention mechanisms are implemented in ``attention.py``.

Model Parameters
~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -90,7 +90,7 @@ optional arguments:
``--reco,-r RECO [RECO ...]``\
Reconstruction task to perform; valid options: particletype, energy, and/or direction
``--default_model,-d DEFAULT_MODEL``\
Default CTLearn Model; valid options: TRN (mono), mergedTRN (stereo), and CNNRNN (stereo)
Default CTLearn Model; valid options: TRN (mono), stackedTRN (stereo), and CNNRNN (stereo)
``--clean, --no-clean``\
Flag, if the network should be trained with cleaned images (default: False)
``--pretrained_weights,-w PRETRAINED_WEIGHTS``\
Expand Down

0 comments on commit 9702347

Please sign in to comment.