MarcBS / keras

Keras' fork with several new functionalities. Caffe2Keras converter, multimodal layers, etc.
https://github.com/MarcBS/keras
Other
225 stars 58 forks source link

Error trying to read model from keras/caffe/models/googleNet_structure.json #13

Open ternaus opened 8 years ago

ternaus commented 8 years ago

I am trying to read googleNet model from an example that may be found in the repository, but I get an error

model = model_from_json(open('models/googleNet_structure.json').read())

File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/models.py", line 36, in model_from_json return layer_from_config(config, custom_objects=custom_objects) File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/utils/layer_utils.py", line 35, in layer_from_config return layer_class.from_config(config['config']) File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/engine/topology.py", line 2271, in from_config process_layer(layer_data) File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/engine/topology.py", line 2249, in process_layer custom_objects=custom_objects) File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/utils/layer_utils.py", line 35, in layer_from_config return layer_class.from_config(config['config']) File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/engine/topology.py", line 896, in from_config return cls(config) File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/layers/convolutional.py", line 283, in init super(Convolution2D, self).init(kwargs) File "/usr/local/lib/python2.7/dist-packages/Keras-1.0.5-py2.7.egg/keras/engine/topology.py", line 302, in init assert kwarg in allowed_kwargs, 'Keyword argument not understood: ' + kwarg AssertionError: Keyword argument not understood: b_learning_rate_multiplier

MarcBS commented 8 years ago

I am using the very same model right now and it is working perfectly fine.

Could it be that you are using the original repository of Keras to load the model? The parameter 'b_learning_rate_multiplier' is specific for this fork and does not exist in the original repo.

ternaus commented 8 years ago

Yes, it was an issue.

Still I have problem with GoogleNet:

I am trying to fine tune, but this requires replacing output. Currently I do:

model.layers.pop()
model.outputs = [model.layers[-1].output]
 model.layers[-1].outbound_nodes = []
 model.add(Dense(10, activation='softmax'))

This worked with VGG16 and original Keras. But I get an error here:

model.add(Dense(10, activation='softmax'))
AttributeError: 'Model' object has no attribute 'add'