signal-grad-cam 1.0.0__tar.gz → 1.0.1__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: signal_grad_cam
3
- Version: 1.0.0
3
+ Version: 1.0.1
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="1.0.0",
8
+ version="1.0.1",
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",
@@ -307,7 +307,7 @@ class CamBuilder:
307
307
  aspect = "auto" if cam.shape[0] / cam.shape[1] < 0.1 else None
308
308
 
309
309
  norm = self.__get_norm(cam)
310
- map = plt.imshow(cam, cmap="jet", aspect=aspect, norm=norm)
310
+ map = plt.imshow(cam, cmap="inferno", aspect=aspect, norm=norm)
311
311
  self.__set_colorbar(bar_ranges_dict[item_key], i)
312
312
  map.set_alpha(0.3)
313
313
 
@@ -335,7 +335,7 @@ class CamBuilder:
335
335
  fig_size: Tuple[int, int] = None, line_width: float = 0.1,
336
336
  marker_width: float = 30) -> None:
337
337
  """
338
- Displays input signal channels, coloring each with "jet" colormat according to the corresponding CAMs. This
338
+ Displays input signal channels, coloring each with "inferno" colormat according to the corresponding CAMs. This
339
339
  visualization is useful for interpreting signal explanations with a limited number of channels. If many channels
340
340
  are present, it is recommended to select only a subset.
341
341
 
@@ -383,7 +383,7 @@ class CamBuilder:
383
383
  :param line_width: (optional, default is 0.1) A numerical value representing the width in typographic points of
384
384
  the black interpolation lines in the plots.
385
385
  :param marker_width: (optional, default is 30) A numerical value representing the size in typographic points**2
386
- of the jet-colored markers in the plots.
386
+ of the inferno-colored markers in the plots.
387
387
  """
388
388
 
389
389
  # Check input types
@@ -432,8 +432,8 @@ class CamBuilder:
432
432
  cam_j = cam[0, :]
433
433
  item_j = item[:, channel] if item.shape[0] == len(cam_j) else item[channel, :]
434
434
  plt.plot(item_j, color="black", linewidth=line_width)
435
- plt.scatter(np.arange(len(item_j)), item_j, c=cam_j, cmap="jet", marker=".",
436
- s=marker_width, norm=None, vmin=minimum, vmax=maximum)
435
+ plt.scatter(np.arange(len(item_j)), item_j, c=cam_j, cmap="inferno", marker=".",
436
+ s=marker_width, norm=None, vmin=minimum, vmax=maximum + 1e-10)
437
437
  self.__set_colorbar(bar_ranges_dict[item_key], i)
438
438
 
439
439
  if channel_names is None:
@@ -739,7 +739,7 @@ class CamBuilder:
739
739
  aspect = 1
740
740
  if not self.time_axs:
741
741
  map = np.transpose(map)
742
- plt.matshow(map, cmap=plt.get_cmap("jet"), norm=norm, aspect=aspect)
742
+ plt.matshow(map, cmap=plt.get_cmap("inferno"), norm=norm, aspect=aspect)
743
743
 
744
744
  # Add color bar
745
745
  self.__set_colorbar(bar_ranges, i)
@@ -1039,13 +1039,13 @@ class CamBuilder:
1039
1039
  list.
1040
1040
  """
1041
1041
 
1042
- bar_range = [bar_ranges[0][batch_idx], bar_ranges[1][batch_idx]]
1043
- cbar = plt.colorbar()
1044
- if bar_range is not None:
1042
+ if bar_ranges is not None:
1043
+ bar_range = [bar_ranges[0][batch_idx], bar_ranges[1][batch_idx]]
1044
+ cbar = plt.colorbar()
1045
1045
  minimum = float(bar_range[0])
1046
1046
  maximum = float(bar_range[1])
1047
1047
  min_str = str(minimum) if minimum == 0 else "{:.2e}".format(minimum)
1048
- max_str = "" if maximum == minimum else "{:.2e}".format(maximum)
1048
+ max_str = str(maximum) if maximum == 0 else "{:.2e}".format(maximum)
1049
1049
  cbar.ax.get_yaxis().set_ticks([cbar.vmin, cbar.vmax], labels=[min_str, max_str])
1050
1050
 
1051
1051
  @staticmethod
@@ -228,8 +228,7 @@ class TorchCamBuilder(CamBuilder):
228
228
  if contrastive_foil_class is None:
229
229
  target_score = target_scores[i, target_class]
230
230
  else:
231
- contrastive_foil = torch.autograd.Variable(torch.from_numpy(np.asarray([contrastive_foil_class]
232
- * target_scores.shape[0])))
231
+ contrastive_foil = torch.autograd.Variable(torch.from_numpy(np.asarray([contrastive_foil_class])))
233
232
  target_score = nn.CrossEntropyLoss()(target_scores[i].unsqueeze(0), contrastive_foil)
234
233
  target_score.backward(retain_graph=True)
235
234
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: signal-grad-cam
3
- Version: 1.0.0
3
+ Version: 1.0.1
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