signal-grad-cam 0.1.5__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of signal-grad-cam might be problematic. Click here for more details.
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/PKG-INFO +1 -1
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/setup.py +1 -1
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam/cam_builder.py +16 -11
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam/pytorch_cam_builder.py +3 -2
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam/tensorflow_cam_builder.py +3 -2
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam.egg-info/PKG-INFO +1 -1
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/LICENSE +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/README.md +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/pyproject.toml +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/setup.cfg +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam/__init__.py +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam.egg-info/SOURCES.txt +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam.egg-info/dependency_links.txt +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam.egg-info/not-zip-safe +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam.egg-info/requires.txt +0 -0
- {signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: signal_grad_cam
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: SignalGrad-CAM aims at generalising Grad-CAM to one-dimensional applications, while enhancing usability and efficiency.
|
|
5
5
|
Home-page: https://github.com/samuelepe11/signal_grad_cam
|
|
6
6
|
Author: Samuele Pe
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="signal_grad_cam",
|
|
8
|
-
version="0.1.
|
|
8
|
+
version="0.1.7",
|
|
9
9
|
description="SignalGrad-CAM aims at generalising Grad-CAM to one-dimensional applications, while enhancing usability"
|
|
10
10
|
" and efficiency.",
|
|
11
11
|
keywords="XAI, class activation maps, CNN, time series",
|
|
@@ -92,15 +92,20 @@ class CamBuilder:
|
|
|
92
92
|
# Show available 1D or 2D convolutional layers
|
|
93
93
|
print()
|
|
94
94
|
print("SEARCHING FOR NETWORK LAYERS:")
|
|
95
|
-
self.__print_justify("Please
|
|
96
|
-
"and note the names of the layers that are of interest to you. If the desired
|
|
97
|
-
" present in the
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
95
|
+
self.__print_justify("Please verify that your network contains at least one 1D or 2D convolutional layer, "
|
|
96
|
+
"and take note of the names of the layers that are of interest to you. If the desired "
|
|
97
|
+
"layer is not present in the list below, it can still be accessed using the name by which "
|
|
98
|
+
"it is defined in the network.\n"
|
|
99
|
+
"Also, check whether the model ends with an activation function from the Softmax family "
|
|
100
|
+
"(such as Sigmoid or Softmax). Even if this activation function is not listed below, you "
|
|
101
|
+
"must indicate its presence using the appropriate argument in the 'get_cam' function. "
|
|
102
|
+
"Note that in binary classification networks (those ending with a Sigmoid function), "
|
|
103
|
+
"overconfident predictions can cause the Sigmoid to saturate, leading to empty or null "
|
|
104
|
+
"maps. To prevent this, modify your network to output logits directly.\n"
|
|
105
|
+
"Make sure the provided model is set to inference mode ('eval') if using PyTorch. For "
|
|
106
|
+
"TensorFlow/Keras models, ensure the model is built—i.e., it must have defined 'inputs' "
|
|
107
|
+
"and 'output' attributes.\n"
|
|
108
|
+
"Network layers found (name: type):")
|
|
104
109
|
self._get_layers_pool(show=True, extend_search=extend_search)
|
|
105
110
|
print()
|
|
106
111
|
|
|
@@ -578,8 +583,8 @@ class CamBuilder:
|
|
|
578
583
|
data_shape_list_processed = [tuple(data_element.shape) for data_element in data_list]
|
|
579
584
|
if len(set(data_shape_list_processed)) != 1:
|
|
580
585
|
data_list = [np.resize(x, data_shape_list_processed[0]) for x in data_list]
|
|
581
|
-
self.__print_justify("
|
|
582
|
-
"first item's dimensions for batching. To prevent this, provide one item at a "
|
|
586
|
+
self.__print_justify("\nInput data items have different shapes. Each item has been reshaped to match the"
|
|
587
|
+
" first item's dimensions for batching. To prevent this, provide one item at a "
|
|
583
588
|
"time.")
|
|
584
589
|
|
|
585
590
|
cam_list, target_probs = self._create_raw_batched_cams(data_list, target_class, target_layer, explainer_type,
|
|
@@ -207,12 +207,13 @@ class TorchCamBuilder(CamBuilder):
|
|
|
207
207
|
if len(outputs.shape) == 2 and outputs.shape[1] > 1:
|
|
208
208
|
target_probs = torch.softmax(target_scores, dim=1)
|
|
209
209
|
else:
|
|
210
|
+
p = torch.sigmoid(outputs)
|
|
210
211
|
if len(outputs.shape) == 1:
|
|
211
212
|
target_scores = torch.stack([-outputs, outputs], dim=1)
|
|
213
|
+
target_probs = torch.stack([1 - p, p], dim=1)
|
|
212
214
|
elif len(outputs.shape) == 2 and outputs.shape[1] == 1:
|
|
213
215
|
target_scores = torch.cat([-outputs, outputs], dim=1)
|
|
214
|
-
|
|
215
|
-
target_probs = torch.stack([1 - p, p], dim=1)
|
|
216
|
+
target_probs = torch.cat([1 - p, p], dim=1)
|
|
216
217
|
|
|
217
218
|
target_probs = target_probs[:, target_class].cpu().detach().numpy()
|
|
218
219
|
|
|
@@ -222,12 +222,13 @@ class TfCamBuilder(CamBuilder):
|
|
|
222
222
|
if len(outputs.shape) == 2 and outputs.shape[1] > 1:
|
|
223
223
|
target_probs = tf.nn.softmax(target_scores, axis=1)
|
|
224
224
|
else:
|
|
225
|
+
p = tf.math.sigmoid(outputs)
|
|
225
226
|
if len(outputs.shape) == 1:
|
|
226
227
|
target_scores = tf.stack([-outputs, outputs], axis=1)
|
|
228
|
+
target_probs = tf.stack([1 - p, p], axis=1)
|
|
227
229
|
elif len(outputs.shape) == 2 and outputs.shape[1] == 1:
|
|
228
230
|
target_scores = tf.concat([-outputs, outputs], axis=1)
|
|
229
|
-
|
|
230
|
-
target_probs = tf.stack([1 - p, p], axis=1)
|
|
231
|
+
target_probs = tf.concat([1 - p, p], axis=1)
|
|
231
232
|
|
|
232
233
|
target_scores = target_scores[:, target_class]
|
|
233
234
|
target_probs = target_probs[:, target_class]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: signal-grad-cam
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: SignalGrad-CAM aims at generalising Grad-CAM to one-dimensional applications, while enhancing usability and efficiency.
|
|
5
5
|
Home-page: https://github.com/samuelepe11/signal_grad_cam
|
|
6
6
|
Author: Samuele Pe
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{signal_grad_cam-0.1.5 → signal_grad_cam-0.1.7}/signal_grad_cam.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|