kundajelab / deeplift

Public facing deeplift repo
MIT License
830 stars 164 forks source link

TypeError: string indices must be integers #71

Closed EoinKenny closed 5 years ago

EoinKenny commented 5 years ago

I just have a normal MNIST CNN and get the following error when running DeepLIFT

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-4145c122a002> in <module>
      4     kc.convert_model_from_saved_files(
      5         "NN.h5",
----> 6         nonlinear_mxts_mode=deeplift.layers.NonlinearMxtsMode.DeepLIFT_GenomicsDefault) 
      7 
      8 # Which layer to propagate contribution scores?

/anaconda3/envs/exp1/lib/python3.6/site-packages/deeplift/conversion/kerasapi_conversion.py in convert_model_from_saved_files(h5_file, json_file, yaml_file, **kwargs)
    361     for layer_config in layer_configs:
    362 
--> 363         layer_name = layer_config["config"]["name"]
    364         assert layer_name in model_weights,\
    365             ("Layer "+layer_name+" is in the layer names but not in the "

TypeError: string indices must be integers

Any idea what this could be? Should I post a whole working example to make it clearer?

AvantiShri commented 5 years ago

Hi Eoin,

Can you please upload NN.h5?

EoinKenny commented 5 years ago

Hi,

Thanks a lot for the quick reply, I'll attach the model here. Strangely enough it didn't always happen with other models, so I'm quite at a loss why this would happen.

Thanks again NN.h5.zip

AvantiShri commented 5 years ago

Hi Eoin,

I tried loading your model with the latest version of deeplift (0.6.8.1) and it worked fine - here's a colab notebook loading the model: https://gist.github.com/AvantiShri/e77ace62219846746537f88ce50388d2

Here's the screenshot:

screen shot 2019-01-11 at 12 21 12 pm

What is your deeplift version? If it's not the latest version, can you try with that?

EoinKenny commented 5 years ago

You were right, I'm really sorry to have asked such a question, I appreciate the help! Have a great day and thanks again.

AvantiShri commented 5 years ago

No worries at all, glad I could help!