0
0
TensorFlowml~10 mins

Why regularization prevents overfitting in TensorFlow - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add L2 regularization to a Dense layer in TensorFlow.

TensorFlow
layer = tf.keras.layers.Dense(64, kernel_regularizer=tf.keras.regularizers.[1](0.01))
Drag options to blanks, or click blank then click option'
Al1
Bl2
Cl1_l2
Ddropout
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'l1' instead of 'l2' for L2 regularization.
2fill in blank
medium

Complete the code to compile the model with mean squared error loss and Adam optimizer.

TensorFlow
model.compile(optimizer='[1]', loss='mse', metrics=['mae'])
Drag options to blanks, or click blank then click option'
Aadagrad
Bsgd
Cadam
Drmsprop
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sgd' which is less adaptive than Adam.
3fill in blank
hard

Fix the error in the code to add dropout regularization after a Dense layer.

TensorFlow
model.add(tf.keras.layers.Dense(128, activation='relu'))
model.add(tf.keras.layers.[1](0.5))
Drag options to blanks, or click blank then click option'
ADropout
BFlatten
CBatchNormalization
DDense
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Dense' instead of 'Dropout' for regularization.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters features with length greater than 3.

TensorFlow
filtered_features = {feature: data[feature] for feature in features if [1](feature) [2] 3}
Drag options to blanks, or click blank then click option'
Alen
B>
C<
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for filtering.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that includes features with values greater than 0.

TensorFlow
positive_features = { [1]: [2] for [3] in data if data[[3]] > 0 }
Drag options to blanks, or click blank then click option'
Afeature
Bdata[feature]
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.