Closed linchundan88 closed 5 years ago
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.
So, if I understood correctly, you call multiple times explain()
with a different xs
but the same Tensors T and X?
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)
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.