question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MNIST Example returns difference in predictions: 1.0

See original GitHub issue

I’m using Google Collab GPU runtime to run MNIST example using Keras 1.2.0.

This snippet from MNIST Example

from deeplift.util import compile_func
import numpy as np
from keras import backend as K

deeplift_model = revealcancel_model
deeplift_prediction_func = compile_func([deeplift_model.get_layers()[0].get_activation_vars()],
                                       deeplift_model.get_layers()[-1].get_activation_vars())
original_model_predictions = keras_model.predict(X_test, batch_size=200)
converted_model_predictions = deeplift.util.run_function_in_batches(
                                input_data_list=[X_test],
                                func=deeplift_prediction_func,
                                batch_size=200,
                                progress_update=None)
print("difference in predictions:",np.max(np.array(converted_model_predictions)-np.array(original_model_predictions)))
assert np.max(np.array(converted_model_predictions)-np.array(original_model_predictions)) < 10**-5
predictions = converted_model_predictions

However, I’m getting the following result:

difference in predictions: 1.0
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-4-3f4204ab927a> in <module>()
     13                                 progress_update=None)
     14 print("difference in predictions:",np.max(np.array(converted_model_predictions)-np.array(original_model_predictions)))
---> 15 assert np.max(np.array(converted_model_predictions)-np.array(original_model_predictions)) < 10**-5
     16 predictions = converted_model_predictions

I used the provided shell script to download .h5 model file.

Furthermore, the Compute Importance Scores snippet results in the following error:

RuntimeError: You set the target layer to an activation layer, which is unusual so I am throwing an error - did you mean to set the target layer to the layer *before* the activation layer instead? (recommended for  classification)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
AvantiShricommented, Jun 6, 2018

Btw, I added an example notebook that works on Keras 2 to the keras2compat branch: https://github.com/kundajelab/deeplift/blob/keras2compat/examples/mnist/MNIST_replicate_figures.ipynb - let me know if you have any issues.

0reactions
donigiancommented, Jun 2, 2018

Excellent, thanks for the clarification, I’ll give it a test drive.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An Introduction to Linear Learner with MNIST
Welcome to our example introducing Amazon SageMaker's Linear Learner Algorithm! Today, we're analyzing the MNIST dataset which consists of images of ...
Read more >
20. Training and Testing with MNIST | Machine Learning
The MNIST dataset is used by researchers to test and compare their research results with others. The lowest error rates in literature are...
Read more >
cloudml-dist-mnist-example/README.md at master - GitHub
This is an example to demonstrate how to write distributed TensorFlow code which can be used on both Cloud Machine Learning Engine and...
Read more >
Evaluating MNIST Accuracy On The Test Set
These datasets contain different sets of images. We will compute the accuracy on the test data set so that we know that the...
Read more >
How to Make Predictions with Keras - Machine Learning Mastery
This is called a probability prediction where, given a new instance, the model returns the probability for each outcome class as a value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found