1
$\begingroup$

I guess the model shown in this image (img_1)

enter image description here

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

enter image description here

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?

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .