<p>You have 3 inputs going to 3 nodes in the input layer. Each connection has a weight so you have  3 X 3 =9 weights. Plus each node has a bias weight so that adds 3 more weights for a total of 12. Your output layer has 3 inputs and is a single node so you have 3 weights for the inputs to the node plus a bias weight for a total of 4. So the total weights in your network is 16.</p>

CC BY-SA 4.0
2020-04-17T16:32:01.000Z
2020-04-17T16:32:01.000Z
Gerry P
<p>I guess the model shown in this image (img_1)</p>

<p><a href="https://i.sstatic.net/xzsN1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xzsN1.png" alt="enter image description here"></a></p>

<p>is the same as <a href="https://youtu.be/fXOsFF95ifk?list=PLkDaE6sCZn6Ec-XTbcX1uRg2_u4xOEky0&amp;t=123" rel="nofollow noreferrer">the one</a> in this image (img_2)</p>

<p><a href="https://i.sstatic.net/AHdjH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AHdjH.png" alt="enter image description here"></a></p>

<p>I was trying to build a neural net like that.</p>

<p>This keras code is to do the job.</p>

<pre><code>model = Sequential()
model.add(Dense(3, input_dim=3, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
plot_model(model, to_file='model_plot.png', show_shapes=True, show_layer_names=True)
</code></pre>

<p>However, <code>print(model.summary())</code> outputs </p>

<pre><code>Model: "sequential_17"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense_31 (Dense)             (None, 3)                 12        
_________________________________________________________________
dense_32 (Dense)             (None, 1)                 4         
=================================================================
</code></pre>

<p>There are 3 <code>w</code>s and 1 <code>b</code> in the hidden layer. Why does this model have 12 parameters?</p>

<neural-networks><machine-learning><keras>
Why does this model have 12 parameters?
Piete3r
# Why does this model have 12 parameters?

(Asked by: username_0 on 2020-04-17)

I guess the model shown in this image (img_1)

is the same as the one in this image (img_2)

I was trying to build a neural net like that.
This keras code is to do the job.
model = Sequential()
model.add(Dense(3, input_dim=3, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
plot_model(model, to_file='model_plot.png', show_shapes=True, show_layer_names=True)

However, print(model.summary()) outputs 
Model: "sequential_17"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense_31 (Dense)             (None, 3)                 12        
_________________________________________________________________
dense_32 (Dense)             (None, 1)                 4         
=================================================================

There are 3 ws and 1 b in the hidden layer. Why does this model have 12 parameters?

**Tags:** neural-networks, machine-learning, keras


---

## 1 answers

### Answer by username_1 on 2020-04-17. Score: 2 | Accepted answer

You have 3 inputs going to 3 nodes in the input layer. Each connection has a weight so you have 3 X 3 =9 weights. Plus each node has a bias weight so that adds 3 more weights for a total of 12. Your output layer has 3 inputs and is a single node so you have 3 weights for the inputs to the node plus a bias weight for a total of 4. So the total weights in your network is 16.


---

