albermax / albermax/innvestigate

project() got an unexpected keyword argument 'input_is_postive_only'

Open
#176 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
1.3k
Forks
230
PR merge metrics
No merged PRs in 30d

Description

when i run the example [mnist_neuron_selection.ipynb](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/mnist_neuron_selection.ipynb), I got this error:
I didn't change any code.
Why this happen? and How can I solve it?

```python
n = 10
test_images = list(zip(data[2][:n], data[3][:n]))

for image_nr, (x, y) in enumerate(test_images):
# Add batch axis.
x = x[None, :, :, :]

analysis = np.zeros([5, len(analyzers), 28, 28, 3])
text = []

for ii, output_neuron in enumerate([4, 5, 6, 8, 9]): #range(num_classes):
# Predict final activations, probabilites, and label.
presm = model_wo_softmax.predict_on_batch(x)[0]
prob = model.predict_on_batch(x)[0]
y_hat = prob.argmax()

# Save prediction info:
text.append(("%s" % label_to_class_name[y], # ground truth label
"%.2f" % presm[output_neuron], # pre-softmax logits
"%.2f" % prob[output_neuron], # probabilistic softmax output
"%s" % label_to_class_name[output_neuron]
))

for aidx, analyzer in enumerate(analyzers):
# Analyze.
a = analyzer.analyze(x, neuron_selection=output_neuron)

# Apply common postprocessing, e.g., re-ordering the channels for plotting.
a = mnistutils.postprocess(a)
# Apply analysis postprocessing, e.g., creating a heatmap.
a = methods[aidx][2](a)
# Store the analysis.
analysis[ii, aidx] = a[0]

print("-"*80)
print("Image nr. {}: ".format(image_nr))
# Prepare the grid as rectengular list
grid = [[analysis[i, j] for j in range(analysis.shape[1])]
for i in range(analysis.shape[0])]
# Prepare the labels
label, presm, prob, pred = zip(*text)
row_labels_left = [('label: {}'.format(label[i]), 'neuron: {}'.format(pred[i])) for i in range(len(label))]
row_labels_right = [('logit: {}'.format(presm[i]), 'prob: {}'.format(prob[i])) for i in range(len(label))]
col_labels = [''.join(method[3]) for method in methods]

# Plot the analysis.
file_name = os.environ.get("PLOTFILENAME", None)
if file_name is not None:
file_name = ".".join(file_name.split(".")[:-1])+("_%i" % output_neuron)+file_name.split(".")[-1]
eutils.plot_image_grid(grid, row_labels_left, row_labels_right, col_labels, file_name=file_name)
```
TypeError Traceback (most recent call last)
in
29 a = mnistutils.postprocess(a)
30 # Apply analysis postprocessing, e.g., creating a heatmap.
---> 31 a = methods[aidx][2](a)
32 # Store the analysis.
33 analysis[ii, aidx] = a[0]

/mnt/boylad/notebook/visual/feature_vis/investigate/utils_mnist.py in graymap(X)
169
170 def graymap(X):
--> 171 return ivis.graymap(np.abs(X), input_is_postive_only=True)

/mnt/boylad/anaconda3/envs/tf1/lib/python3.6/site-packages/innvestigate-1.0.8-py3.6.egg/innvestigate/utils/visualizations.py in graymap(X, **kwargs)
103 def graymap(X, **kwargs):
104 """Same as :func:`heatmap` but uses a gray colormap."""
--> 105 return heatmap(X, cmap_type="gray", **kwargs)
106
107

/mnt/boylad/anaconda3/envs/tf1/lib/python3.6/site-packages/innvestigate-1.0.8-py3.6.egg/innvestigate/utils/visualizations.py in heatmap(X, cmap_type, reduce_op, reduce_axis, alpha_cmap, **kwargs)
88 raise NotImplementedError()
89
---> 90 tmp = project(tmp, output_range=(0, 255), **kwargs).astype(np.int64)
91
92 if alpha_cmap:

**TypeError: project() got an unexpected keyword argument 'input_is_postive_only'**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.