0
0
TensorFlowml~10 mins

CNN architecture for image classification 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 add a convolutional layer with 32 filters and a 3x3 kernel.

TensorFlow
model.add(tf.keras.layers.Conv2D([1], (3, 3), activation='relu', input_shape=(28, 28, 1)))
Drag options to blanks, or click blank then click option'
A32
B128
C16
D64
Attempts:
3 left
💡 Hint
Common Mistakes
Using too few filters like 16 may limit feature extraction.
Using too many filters like 128 can increase computation unnecessarily.
2fill in blank
medium

Complete the code to add a max pooling layer with pool size 2x2.

TensorFlow
model.add(tf.keras.layers.MaxPooling2D(pool_size=[1]))
Drag options to blanks, or click blank then click option'
A(3, 3)
B(1, 1)
C(2, 2)
D(4, 4)
Attempts:
3 left
💡 Hint
Common Mistakes
Using (1, 1) does not reduce the size.
Using (3, 3) or larger may reduce size too much.
3fill in blank
hard

Fix the error in the code to flatten the output before the dense layer.

TensorFlow
model.add(tf.keras.layers.[1]())
Drag options to blanks, or click blank then click option'
ADense
BDropout
CConv2D
DFlatten
Attempts:
3 left
💡 Hint
Common Mistakes
Using Dense instead of Flatten causes shape errors.
Using Conv2D or Dropout here is incorrect.
4fill in blank
hard

Fill both blanks to add a dense layer with 128 units and ReLU activation.

TensorFlow
model.add(tf.keras.layers.Dense([1], activation=[2]))
Drag options to blanks, or click blank then click option'
A128
B'sigmoid'
C'relu'
D64
Attempts:
3 left
💡 Hint
Common Mistakes
Using sigmoid activation in hidden layers can slow learning.
Choosing too few units like 64 may limit model capacity.
5fill in blank
hard

Fill all three blanks to compile the model with Adam optimizer, sparse categorical crossentropy loss, and accuracy metric.

TensorFlow
model.compile(optimizer=[1], loss=[2], metrics=[[3]])
Drag options to blanks, or click blank then click option'
A'sgd'
B'sparse_categorical_crossentropy'
C'accuracy'
D'adam'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sgd' optimizer may require tuning learning rate.
Using 'categorical_crossentropy' instead of sparse version causes errors if labels are integers.