0
0
TensorFlowml~10 mins

Why Keras simplifies model building 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 import Keras from TensorFlow.

TensorFlow
from tensorflow import [1]
Drag options to blanks, or click blank then click option'
Akeras
Bnumpy
Cpandas
Dmatplotlib
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like numpy or pandas instead of keras.
Trying to import keras separately without tensorflow.
2fill in blank
medium

Complete the code to create a simple sequential model in Keras.

TensorFlow
model = keras.models.[1]()
Drag options to blanks, or click blank then click option'
APipeline
BGraph
CModel
DSequential
Attempts:
3 left
💡 Hint
Common Mistakes
Using Model instead of Sequential for simple linear stacks.
Using non-existent classes like Graph or Pipeline.
3fill in blank
hard

Fix the error in adding a dense layer with 10 units and ReLU activation.

TensorFlow
model.add(keras.layers.Dense([1], activation='relu'))
Drag options to blanks, or click blank then click option'
A'ten'
B10
Cunits=10
Dactivation='relu'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the number of units as a string like 'ten'.
Trying to pass keyword arguments inside the first parameter.
4fill in blank
hard

Fill both blanks to compile the model with Adam optimizer and categorical crossentropy loss.

TensorFlow
model.compile(optimizer=[1], loss=[2], metrics=['accuracy'])
Drag options to blanks, or click blank then click option'
A'adam'
B'mse'
C'categorical_crossentropy'
D'binary_crossentropy'
Attempts:
3 left
💡 Hint
Common Mistakes
Using mean squared error (mse) loss for classification.
Using binary crossentropy for multi-class problems.
5fill in blank
hard

Fill all three blanks to train the model on data X_train and y_train for 5 epochs with batch size 32.

TensorFlow
model.fit([1], [2], epochs=[3], batch_size=32)
Drag options to blanks, or click blank then click option'
AX_train
By_train
C5
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping input data and labels.
Using too many epochs without reason.