0
0
TensorFlowml~10 mins

Keras as TensorFlow's high-level API - Interactive Code Practice

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'
Anumpy
Bkeras
Cpandas
Dmatplotlib
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like numpy or pandas instead of keras.
Trying to import keras directly without tensorflow.
2fill in blank
medium

Complete the code to create a Sequential model in Keras.

TensorFlow
model = keras.models.[1]()
Drag options to blanks, or click blank then click option'
AModel
BGraph
CNetwork
DSequential
Attempts:
3 left
💡 Hint
Common Mistakes
Using Model instead of Sequential for a simple stack.
Using undefined classes like Graph or Network.
3fill in blank
hard

Fix the error in the code to add 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'
A10
Brelu
Cunits=10
D'10'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing '10' as a string instead of integer 10.
Using 'units=10' as a positional argument instead of keyword argument.
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'
Aadam
Bcategorical_crossentropy
Cmean_squared_error
Dsgd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sgd' optimizer instead of 'adam'.
Using 'mean_squared_error' loss for classification.
5fill in blank
hard

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

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 X_train and y_train arguments.
Setting epochs to 10 instead of 5.