title: How to implement a neural network with a not-fully-connected layer as the final layer?
body: <p>I would like to implement a neural network with an input layer, two dense hidden layer and a non-dense output layer. A toy example is shown in the figure below. The first hidden layer has three neurons, the second two and the final four neurons but between the second and third there are only four connections.</p>
  <p><a href="https://i.stack.imgur.com/Gdpz7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gdpz7.png" alt="Network architecture" /></a></p>
  <p>I would like to use Keras functional API. How can I implement it? Should I set the missing weight manually to 0? I would start as follows:</p>
  <pre><code>input=keras.layers.Input(...)
  hidden1=keras.layers.Dense(3, activation=&quot;..&quot;)(input)
  hidden2=keras.layers.Dense(3, activation=&quot;..&quot;)(hidden1)
  </code></pre>
  <p>but then I do not know how to proceed.</p>