0
0
Computer Visionml~10 mins

Handwriting recognition basics in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load the MNIST dataset for handwriting recognition.

Computer Vision
from tensorflow.keras.datasets import [1]

(train_images, train_labels), (test_images, test_labels) = [1].load_data()
Drag options to blanks, or click blank then click option'
Amnist
Bcifar10
Cfashion_mnist
Dimdb
Attempts:
3 left
💡 Hint
Common Mistakes
Using CIFAR-10 which is for object images, not handwriting.
Using IMDB which is for text data.
Using Fashion MNIST which is for clothing images.
2fill in blank
medium

Complete the code to normalize the pixel values of the images between 0 and 1.

Computer Vision
train_images = train_images.astype('float32') / [1]
test_images = test_images.astype('float32') / [1]
Drag options to blanks, or click blank then click option'
A256
B100
C1
D255
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing by 100 or 256 which does not scale correctly.
Dividing by 1 which does nothing.
3fill in blank
hard

Fix the error in the model definition by choosing the correct activation function for the output layer.

Computer Vision
from tensorflow.keras import models, layers

model = models.Sequential([
    layers.Flatten(input_shape=(28, 28)),
    layers.Dense(128, activation='relu'),
    layers.Dense(10, activation=[1])
])
Drag options to blanks, or click blank then click option'
A'sigmoid'
B'softmax'
C'relu'
D'tanh'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'relu' or 'tanh' which are not suitable for output probabilities.
Using 'sigmoid' which is for binary classification.
4fill in blank
hard

Fill both blanks to compile the model with the correct loss function and optimizer for handwriting recognition.

Computer Vision
model.compile(optimizer=[1], loss=[2], metrics=['accuracy'])
Drag options to blanks, or click blank then click option'
A'adam'
B'sgd'
C'sparse_categorical_crossentropy'
D'binary_crossentropy'
Attempts:
3 left
💡 Hint
Common Mistakes
Using binary crossentropy which is for binary classification.
Using SGD optimizer without adaptive learning rate.
5fill in blank
hard

Fill all three blanks to train the model for 5 epochs with a batch size of 64 and validate on test data.

Computer Vision
history = model.fit(train_images, train_labels, epochs=[1], batch_size=[2], validation_data=([3], test_labels))
Drag options to blanks, or click blank then click option'
A32
B64
Ctest_images
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using batch size 32 instead of 64 as specified.
Using train_images instead of test_images for validation.