Connecting Functional API models together
See original GitHub issue@fchollet I’m trying to connect 2 functional API models together. here’s the summary of the 2 models:
The First “Input” Model (It works as a single model just fine):
The Second Model that is supposed to be connected to the first model:
I’m trying to connect them together like this:
model = Model(input=generator.input, output=[discriminator.output[0], discriminator.output[1]])
But I get this error:
Graph disconnected: cannot obtain value for tensor discriminator_input at layer “discriminator_input”. The following previous layers were accessed without issue: []
I tried to make a model out of them like this:
Model(input=[generator.input, discriminator.input], output=[discriminator.output[0], discriminator.output[1]])
But this code just resulted in the second Model (and not the 2 of them together), or at least this is what I think after getting a summary of the model and plotting it’s structure.
can we do this in Keras (connecting functional API models) or is there another way? Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (6 by maintainers)
You should connect the output layer of the first network to the input layer of the second network. Something like:
Hi @dieuwkehupkes,
I know it’s an old comment of yours, but it is still helpful. I’m using the same code as you’ve mentioned above to combine 2 separate Keras Models and it works correctly. EXCEPT for one small problem when I want to print out the summary of the newly combined model. When I print out the summary, I get the following output:
The main info from above to look out for is the last layer called
model_1(Model)
. This is actually the model that I connected my first model to which you can see correctly above themodel_1(Model)
layer. What I want is the summary method from keras to print the entire model with all its layers and not justmodel_1(Model)
as it shows above.Do you or does anyone else know how one can achieve this in Keras?