Keras: Unable to save and immediately reload keras model

Created on 23 May 2016  路  5Comments  路  Source: keras-team/keras

I have a script here that

  1. Creates a model
  2. Saves the model by creating a json_string with my_model.to_json and then writing the json_string to a file.
  3. Reloads the model from that file using model_from_json.

The current version of this gist runs and reloads the model fine. But uncommenting lines 25-26 causes an exception when you try and reload the model.The error message is Missing layer: end_img.

This was especially surprising since the line that you uncomment seems not to have any relation to the layer in that error message.

Most helpful comment

I pushed the fix.

All 5 comments

It's an actual bug in the serialization process, that occurs with some specific funky graphs that include shared layers. I'm rolling out a fix.

I pushed the fix.

Thanks. It's amazing how much you do maintaining Keras.

I owe a huge debt to you and the keras community, which I hope to make progress paying back some day.

@fchollet I still faced this issue in keras version 1.1.2.

../keras/engine/topology.pyc in process_layer(layer_data)
   2380                 for input_data in node_data:
   2381                     inbound_layer_name, inbound_node_index, inbound_tensor_index = input_data
-> 2382                     assert inbound_layer_name in created_layers, 'Missing layer: %s' % inbound_layer_name
   2383                     inbound_layer = created_layers[inbound_layer_name]
   2384                     inbound_node = inbound_layer.inbound_nodes[inbound_node_index]

AssertionError: Missing layer: input_1

I have the same issue with version 1.2.0. model_from_json() function throw this error when I try to load the model that I just trained.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarkVdBergh picture MarkVdBergh  路  3Comments

oweingrod picture oweingrod  路  3Comments

braingineer picture braingineer  路  3Comments

LuCeHe picture LuCeHe  路  3Comments

zygmuntz picture zygmuntz  路  3Comments