0
0
TensorFlowml~10 mins

Why training optimizes model weights 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 create a simple model with one dense layer.

TensorFlow
model = tf.keras.Sequential([tf.keras.layers.Dense([1], input_shape=(3,))])
Drag options to blanks, or click blank then click option'
A1
B5
C3
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing too many units for a simple output layer.
2fill in blank
medium

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

TensorFlow
model.compile(optimizer='adam', loss='[1]')
Drag options to blanks, or click blank then click option'
Abinary_crossentropy
Bhinge
Cmean_squared_error
Dcategorical_crossentropy
Attempts:
3 left
💡 Hint
Common Mistakes
Using classification loss functions for regression.
3fill in blank
hard

Fix the error in the training code by filling the correct method name.

TensorFlow
history = model.[1](x_train, y_train, epochs=5)
Drag options to blanks, or click blank then click option'
Afit
Btrain
Crun
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'train' or 'run'.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that stores squared values for even numbers.

TensorFlow
squares = {x: x[1]2 for x in range(1, 6) if x [2] 2 == 0}
Drag options to blanks, or click blank then click option'
A**
B%
C//
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '**' for squaring.
Using '//' instead of '%' for checking evenness.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary with uppercase keys and values greater than zero.

TensorFlow
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'k' instead of 'k.upper()' for keys.
Using '<' instead of '>' for filtering.