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
All layer names should be unique. #130
Comments
How about: base_model = InceptionV3(include_top=False, weights='imagenet',input_shape = (299,299,3))
x = base_model.output
x = GlobalAveragePooling2D(name='special_name_01')(x)
x = Dense(1024, activation='relu', name='special_name_02')(x)
x = Dropout(0.2, name='special_name_03')(x)
predictions = Dense(nbr_classes, activation='softmax', name='special_name_04')(x)
model = Model(input=base_model.input, output=predictions) |
I will retrain the model as you suggested and I will test the script. |
Retraining will not help you, I did also not suggest a that. The error appears because Keras does accidentally reuse layer names. |
Ok, albermax. I will test your proposition. |
In ordre to modify layers name as you sugested :
But I have the same error:
|
I am afraid but this is not what I suggested. base_model = InceptionV3(include_top=False, weights='imagenet',input_shape = (299,299,3))
x = base_model.output
x = GlobalAveragePooling2D(name='special_name_01')(x)
x = Dense(1024, activation='relu', name='special_name_02')(x)
x = Dropout(0.2, name='special_name_03')(x)
predictions = Dense(nbr_classes, activation='softmax', name='special_name_04')(x)
model = Model(input=base_model.input, output=predictions)
# workaround to get unique names
for l in model.layers:
l.name = "%s_workaround" % l.name
# Create model with new names
model = Model(input=model.input, output=model.output) Hope this helps! |
I'm not working with imagnet dataset. For this reason, I'm not using your code. I have already trained a model and I have two files (model.h5, model_weights.h5). |
I have solved the issue but the problem is analyser is very fast with VGG16 but with inceptionV3 is very slow. |
Again you are not very specific. If you need help please provide some example code and more evidence. I close the issue your problems is fixed. |
Could you tell me how you solved it? I'm having the same issue |
I tested the package methods with VGG16 and it works. But, I have tested it with trained InceptionV3 model constructed in separate train script as following:
And loaded in visualisation script as following (I based on imagenet_compare_methods.ipynb) :
I got the following error with iutils.keras.graph.model_wo_softmax function:
To handle this error I have modified the names of my dense layers and I added this code:
These methodes [Input, Gradient] work proprly and SmoothGrad works but with out of memory warning. But with Guided Backprop I got an another error :
Please help me to solve this issue.
The text was updated successfully, but these errors were encountered: