keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.92k stars 19.45k forks source link

Bug: model_from_json crashes on Graphs with create_output=True layer #1915

Closed qdbp closed 8 years ago

qdbp commented 8 years ago

This code:

m = krm.Graph()
m.add_input('x', input_shape=(10,))
m.add_node(klc.Dense(5), 'y', input='x', create_output=True)
m.compile(loss={'y': 'mse'}, optimizer='adam')

with open('test.json', 'w') as f:
    f.write(m.to_json())

with open('test.json', 'r') as f:
    m = krm.model_from_json(f.read())

crashes with the following error:

... models.py", line 166, in model_from_json
... models.py", line 177, in model_from_config
... layer_utils.py", line 64, in container_from_config
... containers.py", line 568, in add_output
    raise Exception('Duplicate output identifier: ' + name)
Exception: Duplicate output identifier: y

I'll see if I can fix it.

qdbp commented 8 years ago

The problem is that create_output is saved as part of the node config. container_from_config's call to create_node therefore creates the output - but then it tries to add the output again, straight from the config.

fchollet commented 8 years ago

Thanks for the notice. This is now fixed.