Open JoshPrim opened 6 years ago
No, the input shape should be the same. Just to double check, are you sure model.layers[4].input
is the input of the concat
layer? Can you try targeting model.layers[4].output
instead? We have never tested Concat layers, but I can try myself if you can provide a minimal working example.
Hey :)
Thanks a lot for your support concerning my problem.
I think I've found a solution. I implemented it as follows:
current_session = K.get_session()
with DeepExplain(session=current_session) as de:
# load the model
model = load_model('model.h5')
predictions = model.predict([input_0, input_1, input_2], verbose=2)
# predict on test data
X_test = [input_0, input_1, input_2]
y_pred = model.predict(X_test)
concat_tensor = model.layers[4].input
input_tensor = model.inputs
concat_out = current_session.run(concat_tensor, {input_tensor[0]: X_test[0], input_tensor[1]: X_test[1], input_tensor[2]: X_test[2]})
xs = X_test
ys = predictions
# Run DeepExplain with the concat-layer as input
attributions = de.explain('elrp', model.layers[-1].output * ys, concat_tensor, concat_out)
print("attributions --- {}".format(attributions))
Once again, thank you very much for your support.
Hey :) Unfortunately, I haven't been able to solve my problem yet.
I tried to implement it as described:
I get in the line:
the following error message:
ValueError: Cannot feed value of shape (3, 1, 10) for Tensor 'input_1_1:0', which has shape '(?, 10)'
Do I have to change my normal input to put it into the concat layer?
Thanks again for the quick help :)