Can anybody explain why param numbers here are 9 and 4? Don’t we use only 3 neurons for layer1 and 1 neuron for layer2?
NVM, I just keep reading the lab and found the answer
I guess you were missing the ‘b’ biases?
To document the answer for future learners:
Lets remember that the linear equation is X*W + b
The input has 2 features (tf.keras.Input(shape=(2,)),)
The layer 1 has 3 units (layers.Dense(3, activation=“sigmoid”, name=“layer1”) ), so the W matrix for layer 1 will be (2,3) = 6, and if we add the biases, that would be 3 more for a total of 9 parameters in layer 1.
The output of layer 1 is 3, which becomes the input of layer 2.
The layer 2 has 1 unit (layers.Dense(1, activation=“sigmoid”, name=“layer2”)), so W = (3,1) = 3 plus the ‘b’ bias, that gives 4 parameters for layer 2.
3 Likes
Thank you! Now they make sense to me