Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ctlearn/core/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ def _get_mono_item(self, batch):
)
if "energy" in self.tasks:
labels["energy"] = batch["log_true_energy"].data
if "impact" in self.tasks:
labels["impact"] = np.stack(
(
batch["true_core_x"].data,
batch["true_core_y"].data,
),
axis=1,
)
if "skydirection" in self.tasks:
labels["skydirection"] = np.stack(
(
Expand Down Expand Up @@ -222,6 +230,7 @@ def _get_stereo_item(self, batch):
features, mono_feature_vectors, stereo_feature_vectors = [], [], []
true_shower_primary_class = []
log_true_energy = []
core_x, core_y = [], []
fov_lon, fov_lat, angular_separation = [], [], []
cam_coord_offset_x, cam_coord_offset_y, cam_coord_distance = [], [], []
for group_element in batch_grouped.groups:
Expand Down Expand Up @@ -260,6 +269,9 @@ def _get_stereo_item(self, batch):
)
if "energy" in self.tasks:
log_true_energy.append(group_element["log_true_energy"].data[0])
if "impact" in self.tasks:
core_x = group_element["true_core_x"].data[0]
core_y = group_element["true_core_y"].data[0]
if "skydirection" in self.tasks:
fov_lon.append(group_element["fov_lon"].data[0])
fov_lat.append(
Expand All @@ -285,6 +297,14 @@ def _get_stereo_item(self, batch):
)
if "energy" in self.tasks:
labels["energy"] = np.array(log_true_energy)
if "impact" in self.tasks:
labels["impact"] = np.stack(
(
np.array(core_x),
np.array(core_y),
),
axis=1,
)
if "skydirection" in self.tasks:
labels["skydirection"] = np.stack(
(
Expand Down
8 changes: 5 additions & 3 deletions ctlearn/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ class CTLearnModel(Component):
"energy": [512, 256, 1],
"cameradirection": [512, 256, 2],
"skydirection": [512, 256, 2],
"impact": [512, 256, 2],
},
allow_none=False,
help=(
"Dictionary containing the number of neurons in the fully connected head for each "
"task ('type', 'energy', 'cameradirection', 'skydirection'). Note: The number of neurons in the last layer "
"task ('type', 'energy', 'cameradirection', 'skydirection', 'impact'). Note: The number of neurons in the last layer "
"must match the number of classes or the number of reconstructed values."
),
).tag(config=True)
Expand All @@ -102,12 +103,13 @@ class CTLearnModel(Component):
"energy": "relu",
"cameradirection": "tanh",
"skydirection": "tanh",
"impact": "tanh",
},
allow_none=False,
help=(
"Dictionary containing the activation function for the fully connected head for each "
"task ('type', 'energy', 'cameradirection', 'skydirection'). Note: The default activation functions "
"are 'relu' for 'type' and 'energy' tasks, and 'tanh' for 'cameradirection' and 'skydirection' tasks. "
"task ('type', 'energy', 'cameradirection', 'skydirection', 'impact'). Note: The default activation functions "
"are 'relu' for 'type' and 'energy' tasks, and 'tanh' for 'cameradirection', 'skydirection' and 'impact' tasks. "
"The 'type' task uses 'softmax' as the final activation function."
),
).tag(config=True)
Expand Down
3 changes: 2 additions & 1 deletion ctlearn/core/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_data_loader(dl1_tmp_path, dl1_gamma_file):
dl1_loader = DLDataLoader(
DLDataReader=dl1_reader,
indices=[0],
tasks=["type", "energy", "cameradirection", "skydirection"],
tasks=["type", "energy", "cameradirection", "skydirection", "impact"],
batch_size=1,
)
# Get the features and labels fgrom the data loader for one batch
Expand All @@ -32,6 +32,7 @@ def test_data_loader(dl1_tmp_path, dl1_gamma_file):
and "energy" in labels
and "cameradirection" in labels
and "skydirection" in labels
and "impact" in labels
)
# Check the shape of the features
assert features["input"].shape == (1, 110, 110, 2)
Loading
Loading