Search code examples
pythonneural-networktheanokerasconv-neural-network

Keras - Connecting Functional API models together


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):

model1

The Second Model that is supposed to be connected to the first model:

model2

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


Solution

  • I asked the question on the Keras Github page and here's the thread about how to solve this problem.