0
0
TensorFlowml~10 mins

Compiling models (optimizer, loss, metrics) 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 compile the model with the Adam optimizer.

TensorFlow
model.compile(optimizer=[1], loss='sparse_categorical_crossentropy', metrics=['accuracy'])
Drag options to blanks, or click blank then click option'
A'adam'
B'sgd'
C'rmsprop'
D'adagrad'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an optimizer name that is not supported or misspelled.
Passing an optimizer object instead of a string.
2fill in blank
medium

Complete the code to compile the model using Mean Squared Error as the loss function.

TensorFlow
model.compile(optimizer='adam', loss=[1], metrics=['mae'])
Drag options to blanks, or click blank then click option'
A'hinge'
B'categorical_crossentropy'
C'binary_crossentropy'
D'mean_squared_error'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a classification loss for a regression problem.
Misspelling the loss function name.
3fill in blank
hard

Fix the error in the code by selecting the correct metric name.

TensorFlow
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=[[1]])
Drag options to blanks, or click blank then click option'
A'precision'
B'acc'
C'accuracy'
D'recall'
Attempts:
3 left
💡 Hint
Common Mistakes
Using deprecated metric names like 'acc'.
Misspelling metric names causing runtime errors.
4fill in blank
hard

Fill both blanks to compile the model with RMSprop optimizer and binary crossentropy loss.

TensorFlow
model.compile(optimizer=[1], loss=[2], metrics=['accuracy'])
Drag options to blanks, or click blank then click option'
A'rmsprop'
B'adam'
C'binary_crossentropy'
D'categorical_crossentropy'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing optimizer and loss function names.
Using categorical loss for binary classification.
5fill in blank
hard

Fill all three blanks to compile the model with SGD optimizer, hinge loss, and precision metric.

TensorFlow
model.compile(optimizer=[1], loss=[2], metrics=[[3]])
Drag options to blanks, or click blank then click option'
A'adam'
B'sgd'
C'hinge'
D'precision'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong optimizer or loss names.
Confusing precision with other metrics.