Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-17T16:32:01.000Z
Answers.LastActivityDate: 2020-04-17T16:32:01.000Z
Answers.UserDisplayName: Gerry P
Body: <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>
  
Tags: <neural-networks><machine-learning><keras>
Title: Why does this model have 12 parameters?
UserDisplayName: Piete3r
ThreadText: # 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)
  
  [![enter image description here](https://i.sstatic.net/xzsN1.png)](https://i.sstatic.net/xzsN1.png)
  
  is the same as [the one](https://youtu.be/fXOsFF95ifk?list=PLkDaE6sCZn6Ec-XTbcX1uRg2_u4xOEky0&t=123) in this image (img\_2)
  
  [![enter image description here](https://i.sstatic.net/AHdjH.png)](https://i.sstatic.net/AHdjH.png)
  
  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 `w`s 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.
  
  
  ---
  
  