Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If I run de.explain multiple times, it becomes slower and slower. #34

Closed
linchundan88 opened this issue Mar 15, 2019 · 3 comments
Closed

Comments

@linchundan88
Copy link

Thank for your work.

If I run de.explain multiple times, it becomes slower and slower.

This problem has not been solved in v0.2.

@linchundan88
Copy link
Author

I developed a RPC service to generate saliency maps using your great library.
I load my models and create DeepExplain session before hand, for every request from RPC client, RPC service invode de.explain. So I found it becomes slower and slower.

@marcoancona
Copy link
Owner

So, if I understood correctly, you call multiple times explain() with a different xs but the same Tensors T and X?

@linchundan88
Copy link
Author

    with DeepExplain(session=K.get_session()) as de:  # <-- init DeepExplain context
        input_tensor = model.layers[0].input

        fModel = Model(inputs=input_tensor, outputs=model.layers[-1].output)
        target_tensor = fModel(input_tensor)

        xs = img_preprocess
        ys = keras.utils.to_categorical([pred], NUM_CLASSES)

        for i in range(TEST_NUM):
            time1 = time.time()  #2 second faster than before   DeepExplain(session=K.get_session()) as de:
            attributions = de.explain('deeplift', target_tensor * ys, input_tensor, xs, batch_size=1)
            # attributions = de.explain('deeplift', target_tensor, input_tensor, xs, ys=ys)
            # attributions = de.explain('elrp', target_tensor * ys, input_tensor, xs, batch_size=1)
            # attributions = de.explain('shapley_sampling', target_tensor, input_tensor, xs, ys=ys, samples=100)
            time2 = time.time()
            print(time2-time1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants