C2W1_Lab_Coffee Roasting in Tensorflow

I am not sure why set the units = 3 in the first layer. Please see the code below. There are only total 2 features, duration and temperature. How can the neuron be as 3? Thank you for the help.

tf.random.set_seed(1234) # applied to achieve consistent results
model = Sequential(
Dense(3, activation=‘sigmoid’, name = ‘layer1’),
Dense(1, activation=‘sigmoid’, name = ‘layer2’)

HI @Kaitlyn_Hu

The input layer is tf.keras.Input(shape=(2,)) shape is 2 is equal 2 features we have it is called input layer and after the input layer Dense(3 , …) is called layer 1 not the input layer and number of units is optional not related with the features we have …because an input layer is the only related layer to and input features


Dense(3…) refers to the number of units in the first hidden layer.

Thank you. I am not sure if choosing three units are correct here, since there are only two inputs.

It’s the number of units in the first hidden layer.
The input layer size (2 units) is specified here:


Hello @Kaitlyn_Hu,

The number of features in the input data doesn’t impose any limit to the choice of number of units in any hidden layer. We pick a choice that gives us the best cv performance which you will learn more in course 2 week 3.


1 Like

Thank you very much!

You are welcome @Kaitlyn_H, and Happy New Year!