0
0
TensorFlowml~10 mins

Dropout layers in TensorFlow - Interactive Code Practice

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

Complete the code to add a dropout layer with 0.3 dropout rate.

TensorFlow
model = tf.keras.Sequential([
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dropout([1]),
    tf.keras.layers.Dense(10, activation='softmax')
])
Drag options to blanks, or click blank then click option'
ANone
B3
C30
D0.3
Attempts:
3 left
💡 Hint
Common Mistakes
Using an integer instead of a decimal for dropout rate.
Setting dropout rate greater than 1 or less than 0.
2fill in blank
medium

Complete the code to import the Dropout layer from TensorFlow Keras.

TensorFlow
from tensorflow.keras.layers import [1]
Drag options to blanks, or click blank then click option'
ADense
BDropout
CFlatten
DConv2D
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Dense or other layers instead of Dropout.
Forgetting to import the Dropout layer.
3fill in blank
hard

Fix the error in the dropout layer definition by completing the code.

TensorFlow
dropout_layer = tf.keras.layers.Dropout(rate=[1])
Drag options to blanks, or click blank then click option'
A0.5
B3
C-0.1
D1.5
Attempts:
3 left
💡 Hint
Common Mistakes
Using values greater than 1 or less than 0 for dropout rate.
Using integers instead of decimals.
4fill in blank
hard

Fill both blanks to create a dropout layer with 0.4 rate and apply it to input tensor x.

TensorFlow
dropout = tf.keras.layers.[1](rate=[2])
x_dropped = dropout(x)
Drag options to blanks, or click blank then click option'
ADropout
BDense
C0.4
D0.8
Attempts:
3 left
💡 Hint
Common Mistakes
Using Dense instead of Dropout layer.
Using dropout rate greater than 1.
5fill in blank
hard

Fill all three blanks to define a model with input layer, dropout with 0.25 rate, and output layer.

TensorFlow
model = tf.keras.Sequential([
    tf.keras.layers.InputLayer(input_shape=(784,)),
    tf.keras.layers.[1](128, activation='relu'),
    tf.keras.layers.Dropout(rate=[2]),
    tf.keras.layers.[3](10, activation='softmax')
])
Drag options to blanks, or click blank then click option'
ADense
B0.25
DDropout
Attempts:
3 left
💡 Hint
Common Mistakes
Using Dropout instead of Dense for hidden or output layers.
Setting dropout rate incorrectly.