<p dir="auto">Hi,<br>
I design a network which composes of shared layers, I write code using functional API. However, there always be errors.<br>
I paste my network structure graph , code , and error information below, hope to provide a clue.<br>
Thanks!</p>
<p dir="auto">Network Structure:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://raw.githubusercontent.com/ylqfp/attachments/bb396650622b37b2a311d29864795aec67301042/cnn2_2_lstm.jpg"><img src="https://raw.githubusercontent.com/ylqfp/attachments/bb396650622b37b2a311d29864795aec67301042/cnn2_2_lstm.jpg" alt="network structure jpeg" style="max-width: 100%;"></a><br>
Share layers:</p>
<ol dir="auto">
<li>Embedding is shared among 3 input.(blue color). However, input_length is different for input1/input2 and input3. The input_length for input1/input2 is LSTM_MAXLEN, 1000, for input3 is QUERY_MAXLEN, 5, eg. max 5 words for a query.</li>
<li>CNN feature learning layer is shared between input1 and input2. (green color)</li>
</ol>
<p dir="auto">I'm trying to create a neural network "within" a neural network, basically I branch off from an intermediate layer, use that as an output to train another neural network. I want to train both networks together. I can't seem to do it, I run into the following error:</p>
<p dir="auto"><em>UserWarning: Model inputs must come from a Keras Input layer, they cannot be the output of a previous non-Input layer</em></p>
<p dir="auto">Sample code below:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# 1st NN: Simple convolutional autoencoder
input_img = Input(shape=(1, 80, 80), name=&quot;input_layer&quot;)
intermediate = Convolution2D(32, 3, 3, subsample=(2, 2))(input_img)
decoded = Deconvolution2D(1, 3, 3, subsample=(2, 2))(intermediate)

#2nd NN: Uses output from encoding part to do supervised learning on FC layers
fc_flatten = Flatten()(intermediate)
y = Dense(64)(fc_flatten)
fc_output = Dense(1)(y)

model = Model(input=[input_img, fc_flatten], output=[decoded, fc_output])"><pre class="notranslate"><code class="notranslate"># 1st NN: Simple convolutional autoencoder
input_img = Input(shape=(1, 80, 80), name="input_layer")
intermediate = Convolution2D(32, 3, 3, subsample=(2, 2))(input_img)
decoded = Deconvolution2D(1, 3, 3, subsample=(2, 2))(intermediate)

#2nd NN: Uses output from encoding part to do supervised learning on FC layers
fc_flatten = Flatten()(intermediate)
y = Dense(64)(fc_flatten)
fc_output = Dense(1)(y)

model = Model(input=[input_img, fc_flatten], output=[decoded, fc_output])
</code></pre></div>
<p dir="auto">I don't understand. I'm using almost the same architecture as the "Multi-input and multi-output models" example on the Keras Functional API, with the exception that I don't have an auxillary input.</p>