Skip to content

Commit c1556ca

Browse files
committed
move listification to losses
1 parent 952b6cd commit c1556ca

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

vis/losses.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, layer, filter_indices):
7171
super(ActivationMaximization, self).__init__()
7272
self.name = "ActivationMax Loss"
7373
self.layer = layer
74-
self.filter_indices = filter_indices
74+
self.filter_indices = utils.listify(filter_indices)
7575

7676
def build_loss(self):
7777
layer_output = self.layer.output

vis/visualization.py

-12
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ def visualize_class_activation(model, layer_idx, filter_indices=None, seed_input
168168
Returns:
169169
The model input that maximizes the output of `filter_indices` in the given `layer_idx`.
170170
"""
171-
filter_indices = utils.listify(filter_indices)
172-
print("Working on filters: {}".format(pprint.pformat(filter_indices)))
173-
174171
losses = [
175172
(ActivationMaximization(model.layers[layer_idx], filter_indices), act_max_weight),
176173
(LPNorm(model.input), lp_norm_weight),
@@ -219,9 +216,6 @@ def visualize_regression_activation(model, layer_idx, output_indices, targets, s
219216
Returns:
220217
The model input that causes regression `output_indices` outputs to approach their corresponding `targets`.
221218
"""
222-
output_indices = utils.listify(output_indices)
223-
print("Working on output indices: {}".format(pprint.pformat(output_indices)))
224-
225219
losses = [
226220
(RegressionTarget(model.layers[layer_idx], output_indices, targets), reg_target_weight),
227221
(LPNorm(model.input), lp_norm_weight),
@@ -290,9 +284,6 @@ def visualize_class_saliency(model, layer_idx, filter_indices, seed_input):
290284
The heatmap image indicating the `seed_input` regions whose change would most contribute towards
291285
maximizing the output of `filter_indices`.
292286
"""
293-
filter_indices = utils.listify(filter_indices)
294-
print("Working on filters: {}".format(pprint.pformat(filter_indices)))
295-
296287
# `ActivationMaximization` loss reduces as outputs get large, hence negative gradients indicate the direction
297288
# for increasing activations. Multiply with -1 so that positive gradients indicate increase instead.
298289
losses = [
@@ -328,9 +319,6 @@ def visualize_regression_saliency(model, layer_idx, output_indices, targets, see
328319
The heatmap image indicating the `seed_input` regions whose change would most contribute towards `output_indices`
329320
outputs to approach their corresponding `targets`.
330321
"""
331-
output_indices = utils.listify(output_indices)
332-
print("Working on filters: {}".format(pprint.pformat(output_indices)))
333-
334322
# `RegressionTarget` loss reduces as outputs approach target, hence negative gradients indicate this direction.
335323
# Multiply with -1 so that positive gradients indicate this direction instead.
336324
losses = [

0 commit comments

Comments
 (0)