Skip to content
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

Deeplift with Cifar10 #124

Open
GizemAyas517 opened this issue Sep 26, 2021 · 3 comments
Open

Deeplift with Cifar10 #124

GizemAyas517 opened this issue Sep 26, 2021 · 3 comments

Comments

@GizemAyas517
Copy link

Hello,

Before getting into my question, just wanted to say I really enjoyed reading the paper and also exploring the codebase. Many thanks for deeplift!

I've been trying to use deeplift with cifar10 but I've came across a problem:

the model and cifar10 dataset I've been using: https://machinelearningmastery.com/object-recognition-convolutional-neural-networks-keras-deep-learning-library/

I save the trained model with the command below:
model.save('my_cifar_model.h5', save_format='h5')

when I run this command everything seems fine:
import keras saved_model_file = "my_cifar_model.h5" model = keras.models.load_model(saved_model_file) model.summary()

However when I try to create a deeplift reveal cancel model:

`import deeplift
from deeplift.layers import NonlinearMxtsMode
from deeplift.conversion import kerasapi_conversion as kc

revealcancel_model = kc.convert_model_from_saved_files(
h5_file=saved_model_file,
nonlinear_mxts_mode=NonlinearMxtsMode.RevealCancel)
`
I get this error: TypeError: can only concatenate str (not "KeysViewHDF5") to str
What do you think I can do to solve it? Are there any deeplift examples with cifar10?

Thanks!

@sidvijay10
Copy link

did you end up fixing this issue?

@N1Keey
Copy link

N1Keey commented Aug 9, 2022

I Have the same problem.. Also trying to apply deeplift on a model which was trained with the cifar10 dataset.
I use the same model from the Tutorial:
Model: "sequential"

Layer (type) Output Shape Param

conv2d (Conv2D) (None, 32, 32, 32) 896

conv2d_1 (Conv2D) (None, 32, 32, 32) 9248

max_pooling2d (MaxPooling2D (None, 16, 16, 32) 0
)

dropout (Dropout) (None, 16, 16, 32) 0

conv2d_2 (Conv2D) (None, 16, 16, 64) 18496

conv2d_3 (Conv2D) (None, 16, 16, 64) 36928

max_pooling2d_1 (MaxPooling (None, 8, 8, 64) 0
2D)

dropout_1 (Dropout) (None, 8, 8, 64) 0

conv2d_4 (Conv2D) (None, 8, 8, 128) 73856

conv2d_5 (Conv2D) (None, 8, 8, 128) 147584

max_pooling2d_2 (MaxPooling (None, 4, 4, 128) 0
2D)

dropout_2 (Dropout) (None, 4, 4, 128) 0

flatten (Flatten) (None, 2048) 0

dense (Dense) (None, 128) 262272

dropout_3 (Dropout) (None, 128) 0

dense_1 (Dense) (None, 10) 774

=================================================================
Total params: 550,054
Trainable params: 550,054
Non-trainable params: 0


The code for the DeepLIFT implementation is from the MNIST-example:
Code:

import deeplift
from deeplift.layers import NonlinearMxtsMode
from deeplift.conversion import kerasapi_conversion as kc
deeplift_model =\
    kc.convert_model_from_saved_files(
        h5_file='model4cifar10.h5',
        nonlinear_mxts_mode=deeplift.layers.NonlinearMxtsMode.DeepLIFT_GenomicsDefault) 

And I get the exact same errormessage.

@AvantiShri
Copy link
Collaborator

AvantiShri commented Oct 28, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants