-
Notifications
You must be signed in to change notification settings - Fork 3.4k
DeepExplainer doesn't work with keras concatenate layers #305
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
Comments
The 1th input is the second (axis) argument so it looks like you have an axis that depends on your inputs...is that supposed to be true? Typically people don't choose the axis they concat with based on the model inputs. |
I think you misread the notation around I get the same error using the following network:
The final error line (same as @ellehoej ):
Is the I am using
|
There must be an issue with the assertion then, causing Concatenate to
break. I will look into it as soon as I can, it could be that the assertion
is checking the wrong input.
…On Mon, Nov 5, 2018 at 1:25 AM Lasse Regin Nielsen ***@***.***> wrote:
I think you misread the notation @slundberg <https://github.com/slundberg>
.
# Define inputs
input_features = Input(shape=(n_features_input,))
input_embeddings = Input(shape=(1,))
# Define embeddings
x_embeddings = Embedding(input_dim=n_stations, output_dim=embedding_size)(input_embeddings)
x_embeddings = Reshape((embedding_size, ))(x_embeddings)
# Concatenate
x = Concatenate(axis=1)([input_features, x_embeddings])
# Layers
x = Dense(512, kernel_initializer='normal', activation='relu')(x)
x = Dense(256, kernel_initializer='normal', activation='relu')(x)
output = Dense(1, activation='linear')(x)
# Compile model
model = Model(
inputs=[input_features, input_stations, input_vis_codes],
outputs=output)
model.compile(
loss='mean_squared_error',
optimizer=keras.optimizers.Adam(lr=learning_rate),
metrics=['mse'])
and I get the same error as @ellehoej <https://github.com/ellehoej>
AssertionError: 1th input to concatenate_10/concat cannot vary!
Is the Concatenate layer just not supported in shap?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#305 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADkTxW8ACQmBfb2X8txlMw19ZeaQf1M7ks5usAP8gaJpZM4X_NKx>
.
|
Thank you very much @slundberg ! Let me know if you need anything from me. |
@LasseRegin do you happen to already have a complete notebook that demonstrates the problem? If not I can build one. |
I created a new (simplified) Notebook demonstrating the problem. It can be found here: |
Hi @slundberg,
The model summary is then:
Gives us the error. Best regards |
Excellent, @LasseRegin! |
Thanks @LasseRegin for the setup! I found and fixed the problem. |
That is great @slundberg ! Thank you very much! |
Thanks for the quick fix and for a great package in general @slundberg , it works in our end as well now. |
Hi,
Thanks for some great work.
I'm getting an error (see below) when using DeepExplainer (SHAP 0.24, TF 1.8, Keras 2.2.4) on a keras model that uses "concatenate" through the Keras functional API.
The model is simply:
Generating the DeepExplainer works:
But when generating shap_values:
I get the following error:
The text was updated successfully, but these errors were encountered: