0
0
TensorFlowml~10 mins

Prediction and evaluation 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 make predictions using the trained model.

TensorFlow
predictions = model.[1](x_test)
Drag options to blanks, or click blank then click option'
Afit
Bcompile
Cevaluate
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' instead of 'predict' which trains the model.
Using 'evaluate' which returns loss and metrics, not predictions.
2fill in blank
medium

Complete the code to evaluate the model on test data and get the loss.

TensorFlow
loss, accuracy = model.[1](x_test, y_test)
Drag options to blanks, or click blank then click option'
Aevaluate
Bcompile
Cfit
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict' which returns predictions, not loss or accuracy.
Using 'fit' which trains the model instead of evaluating.
3fill in blank
hard

Fix the error in the code to correctly compute accuracy from predictions.

TensorFlow
accuracy = tf.keras.metrics.Accuracy()
accuracy.update_state(y_true, [1])
result = accuracy.result().numpy()
Drag options to blanks, or click blank then click option'
Ay_pred
Bmodel.predict(x_test)
Cy_test
Dy_true
Attempts:
3 left
💡 Hint
Common Mistakes
Passing true labels twice instead of predictions.
Passing the model call instead of prediction results.
4fill in blank
hard

Fill both blanks to compute predictions and then evaluate loss and accuracy.

TensorFlow
y_pred = model.[1](x_val)
loss, acc = model.[2](x_val, y_val)
Drag options to blanks, or click blank then click option'
Apredict
Bevaluate
Cfit
Dcompile
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fit' instead of 'evaluate' for performance metrics.
Using 'compile' which only sets up the model.
5fill in blank
hard

Fill all three blanks to compute accuracy using TensorFlow metrics after prediction.

TensorFlow
y_pred = model.[1](x_test)
accuracy_metric = tf.keras.metrics.[2]()
accuracy_metric.update_state(y_test, [3])
accuracy = accuracy_metric.result().numpy()
Drag options to blanks, or click blank then click option'
Apredict
BAccuracy
Cy_pred
DPrecision
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Precision' metric instead of 'Accuracy'.
Passing true labels twice instead of predicted labels.