4
votes

Instruction of questions:

  1. Instantiate a Sequential model.
  2. Add a Dense layer of 50 neurons with an input shape of 1 neuron.
  3. Add two Dense layers of 50 neurons each and 'relu' activation.
  4. End your model with a Dense layer with a single neuron and no activation.

Below is my code:

# Instantiate a Sequential model
model = Sequential()

# Add a Dense layer with 50 neurons and an input of 1 neuron
model.add(Dense(50, input_shape=(2,), activation='relu'))

# Add two Dense layers with 50 neurons and relu activation
model.add(Dense(____,____=____))
model.____

# End your model with a Dense layer and no activation
model.____

I am confused about the part

model.add(Dense(____,____=____))
2

2 Answers

1
votes

In the documentation, the only required parameter for the Dense layer is units, which is the number of neurons. The default activation function is None, so if you want it to be "relu", do activation="relu".

In conclusion, this is that piece of code that creates a Dense layer with 50 neurons and activation as relu:

model.add(Dense(50, activation="relu"))
1
votes

In model.add(Dense(___,___=___)), you have three blanks. The first one is for mentioning number of neurons, the second one for saying that you want to set some value for activation and the third one is for setting that value as relu.

So you will get model.add(Dense(50,activation='relu'))

More information can be found in the Dense layer documentation.