deeplift icon indicating copy to clipboard operation
deeplift copied to clipboard

Sequential model input layer convert

Open yanwang271 opened this issue 3 years ago • 3 comments

Hi Avanti,

I was trying to apply DeepLIFT to a sequential model. When using "kc.convert_model_from_saved_files" function, it gave error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "deeplift/deeplift/conversion/kerasapi_conversion.py", line 388, in convert_model_from_saved_files
    +" weights file which has layer names "+str(model_weights.keys()))
AssertionError: Layer conv1d_3_input is in the layer names but not in the  weights file which has layer names <KeysViewHDF5 ['conv1d', 'conv1d_1', 'conv1d_2', 'conv1d_3', 'dense', 'dense_1', 'dropout', 'dropout_1', 'flatten', 'max_pooling1d', 'max_pooling1d_1']>

The conv1d_3_input is the input layer, which should not have weights. Could you help me with it?

If it helps, below is part of the model config:

{'name': 'sequential', 'layers': [{'class_name': 'InputLayer', 'config': {'batch_input_shape': [None, 500, 4], 'dtype': 'float32', 'sparse': False, 'ragged': False, 'name': 'conv1d_3_input'}}, {'class_name': 'Conv1D', 'config': {'name': 'conv1d_3', 'trainable': True, 'batch_input_shape': [None, 500, 4], 'dtype': 'float32', 'filters': 32, 'kernel_size': [12], 'strides': [1], 'padding': 'valid', 'data_format': 'channels_last', 'dilation_rate': [1], 'groups': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}}, {'class_name': 'Conv1D', 'config': {'name': 'conv1d_2', 'trainable': True, 'dtype': 'float32', 'filters': 32, 'kernel_size': [12], 'strides': [1], 'padding': 'valid', 'data_format': 'channels_last', 'dilation_rate': [1], 'groups': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}}, ...

Thanks! Yan

yanwang271 avatar Mar 06 '22 22:03 yanwang271

Hey man real talk. I hate this stupid project because it has been associated with very bad trauma for me (a trusted friend and colleague suddenly behaved like a very horrible bully to me). And so I probably won’t respond to you for a while because I seriously hate thinking about deeplift. And I gotta ask you: aren’t there more interesting things to think about? After all deeplift is just another made up explanation.

On Sun, Mar 6, 2022 at 2:28 PM yanwang271 @.***> wrote:

Hi Avanti,

I was trying to apply DeepLIFT to a sequential model. When using "kc.convert_model_from_saved_files" function, it gave error:

Traceback (most recent call last): File "", line 1, in File "deeplift/deeplift/conversion/kerasapi_conversion.py", line 388, in convert_model_from_saved_files +" weights file which has layer names "+str(model_weights.keys())) AssertionError: Layer conv1d_3_input is in the layer names but not in the weights file which has layer names <KeysViewHDF5 ['conv1d', 'conv1d_1', 'conv1d_2', 'conv1d_3', 'dense', 'dense_1', 'dropout', 'dropout_1', 'flatten', 'max_pooling1d', 'max_pooling1d_1']>

The conv1d_3_input is the input layer, which should not have weights. Could you help me with it?

If it helps, below is part of the model config:

{'name': 'sequential', 'layers': [{'class_name': 'InputLayer', 'config': {'batch_input_shape': [None, 500, 4], 'dtype': 'float32', 'sparse': False, 'ragged': False, 'name': 'conv1d_3_input'}}, {'class_name': 'Conv1D', 'config': {'name': 'conv1d_3', 'trainable': True, 'batch_input_shape': [None, 500, 4], 'dtype': 'float32', 'filters': 32, 'kernel_size': [12], 'strides': [1], 'padding': 'valid', 'data_format': 'channels_last', 'dilation_rate': [1], 'groups': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}}, {'class_name': 'Conv1D', 'config': {'name': 'conv1d_2', 'trainable': True, 'dtype': 'float32', 'filters': 32, 'kernel_size': [12], 'strides': [1], 'padding': 'valid', 'data_format': 'channels_last', 'dilation_rate': [1], 'groups': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}}, ...

Thanks! Yan

— Reply to this email directly, view it on GitHub https://github.com/kundajelab/deeplift/issues/129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARSFBUQA4CILRZY5UH64A3U6UWQLANCNFSM5QBWLTZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Sent from my phone, please excuse brevity/typos

AvantiShri avatar Mar 06 '22 22:03 AvantiShri

Yan - Apologies for that response from Av. I don't think she has the bandwidth at the moment to answer your questions.

I would suggest switching over the the SHAP repo which has a flexible implementation of a version of DeepLIFT (DeepSHAP / DeepExplainer) https://github.com/slundberg/shap .

Thanks Anshul

On Sun, Mar 6, 2022, 2:31 PM Av Shrikumar @.***> wrote:

Hey man real talk. I hate this stupid project because it has been associated with very bad trauma for me (a trusted friend and colleague suddenly behaved like a very horrible bully to me). And so I probably won’t respond to you for a while because I seriously hate thinking about deeplift. And I gotta ask you: aren’t there more interesting things to think about? After all deeplift is just another made up explanation.

On Sun, Mar 6, 2022 at 2:28 PM yanwang271 @.***> wrote:

Hi Avanti,

I was trying to apply DeepLIFT to a sequential model. When using "kc.convert_model_from_saved_files" function, it gave error:

Traceback (most recent call last): File "", line 1, in File "deeplift/deeplift/conversion/kerasapi_conversion.py", line 388, in convert_model_from_saved_files +" weights file which has layer names "+str(model_weights.keys())) AssertionError: Layer conv1d_3_input is in the layer names but not in the weights file which has layer names <KeysViewHDF5 ['conv1d', 'conv1d_1', 'conv1d_2', 'conv1d_3', 'dense', 'dense_1', 'dropout', 'dropout_1', 'flatten', 'max_pooling1d', 'max_pooling1d_1']>

The conv1d_3_input is the input layer, which should not have weights. Could you help me with it?

If it helps, below is part of the model config:

{'name': 'sequential', 'layers': [{'class_name': 'InputLayer', 'config': {'batch_input_shape': [None, 500, 4], 'dtype': 'float32', 'sparse': False, 'ragged': False, 'name': 'conv1d_3_input'}}, {'class_name': 'Conv1D', 'config': {'name': 'conv1d_3', 'trainable': True, 'batch_input_shape': [None, 500, 4], 'dtype': 'float32', 'filters': 32, 'kernel_size': [12], 'strides': [1], 'padding': 'valid', 'data_format': 'channels_last', 'dilation_rate': [1], 'groups': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}}, {'class_name': 'Conv1D', 'config': {'name': 'conv1d_2', 'trainable': True, 'dtype': 'float32', 'filters': 32, 'kernel_size': [12], 'strides': [1], 'padding': 'valid', 'data_format': 'channels_last', 'dilation_rate': [1], 'groups': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}}, ...

Thanks! Yan

— Reply to this email directly, view it on GitHub https://github.com/kundajelab/deeplift/issues/129, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AARSFBUQA4CILRZY5UH64A3U6UWQLANCNFSM5QBWLTZA

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Sent from my phone, please excuse brevity/typos

— Reply to this email directly, view it on GitHub https://github.com/kundajelab/deeplift/issues/129#issuecomment-1060052147, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABDWEKB2YPJJTX3Y2ZHFODU6UW5FANCNFSM5QBWLTZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

akundaje avatar Mar 06 '22 22:03 akundaje

Sincerely sorry if I appeared angry. I was trying to inspire you

On Sun, Mar 6, 2022 at 2:42 PM Anshul Kundaje @.***> wrote:

Yan - Apologies for that response from Av. I don't think she has the bandwidth at the moment to answer your questions.

I would suggest switching over the the SHAP repo which has a flexible implementation of a version of DeepLIFT (DeepSHAP / DeepExplainer) https://github.com/slundberg/shap .

Thanks Anshul

On Sun, Mar 6, 2022, 2:31 PM Av Shrikumar @.***> wrote:

Hey man real talk. I hate this stupid project because it has been associated with very bad trauma for me (a trusted friend and colleague suddenly behaved like a very horrible bully to me). And so I probably won’t respond to you for a while because I seriously hate thinking about deeplift. And I gotta ask you: aren’t there more interesting things to think about? After all deeplift is just another made up explanation.

On Sun, Mar 6, 2022 at 2:28 PM yanwang271 @.***> wrote:

Hi Avanti,

I was trying to apply DeepLIFT to a sequential model. When using "kc.convert_model_from_saved_files" function, it gave error:

Traceback (most recent call last): File "", line 1, in File "deeplift/deeplift/conversion/kerasapi_conversion.py", line 388, in convert_model_from_saved_files +" weights file which has layer names "+str(model_weights.keys())) AssertionError: Layer conv1d_3_input is in the layer names but not in the weights file which has layer names <KeysViewHDF5 ['conv1d', 'conv1d_1', 'conv1d_2', 'conv1d_3', 'dense', 'dense_1', 'dropout', 'dropout_1', 'flatten', 'max_pooling1d', 'max_pooling1d_1']>

The conv1d_3_input is the input layer, which should not have weights. Could you help me with it?

If it helps, below is part of the model config:

{'name': 'sequential', 'layers': [{'class_name': 'InputLayer', 'config': {'batch_input_shape': [None, 500, 4], 'dtype': 'float32', 'sparse': False, 'ragged': False, 'name': 'conv1d_3_input'}}, {'class_name': 'Conv1D', 'config': {'name': 'conv1d_3', 'trainable': True, 'batch_input_shape': [None, 500, 4], 'dtype': 'float32', 'filters': 32, 'kernel_size': [12], 'strides': [1], 'padding': 'valid', 'data_format': 'channels_last', 'dilation_rate': [1], 'groups': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}}, {'class_name': 'Conv1D', 'config': {'name': 'conv1d_2', 'trainable': True, 'dtype': 'float32', 'filters': 32, 'kernel_size': [12], 'strides': [1], 'padding': 'valid', 'data_format': 'channels_last', 'dilation_rate': [1], 'groups': 1, 'activation': 'relu', 'use_bias': True, 'kernel_initializer': {'class_name': 'GlorotUniform', 'config': {'seed': None}}, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'kernel_regularizer': None, 'bias_regularizer': None, 'activity_regularizer': None, 'kernel_constraint': None, 'bias_constraint': None}}, ...

Thanks! Yan

— Reply to this email directly, view it on GitHub https://github.com/kundajelab/deeplift/issues/129, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AARSFBUQA4CILRZY5UH64A3U6UWQLANCNFSM5QBWLTZA

. Triage notifications on the go with GitHub Mobile for iOS <

https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android <

https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub

.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Sent from my phone, please excuse brevity/typos

— Reply to this email directly, view it on GitHub < https://github.com/kundajelab/deeplift/issues/129#issuecomment-1060052147 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AABDWEKB2YPJJTX3Y2ZHFODU6UW5FANCNFSM5QBWLTZA

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/kundajelab/deeplift/issues/129#issuecomment-1060053667, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARSFBWZDLOKOSPL6OZNIXTU6UYFTANCNFSM5QBWLTZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

-- Sent from my phone, please excuse brevity/typos

AvantiShri avatar Mar 07 '22 01:03 AvantiShri