0
0
Computer Visionml~10 mins

Image datasets (CIFAR-10, ImageNet) 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 CIFAR-10 dataset using TensorFlow.

Computer Vision
import tensorflow as tf
(cifar_train, cifar_test) = tf.keras.datasets.cifar10.[1]()
Drag options to blanks, or click blank then click option'
Aload_data
Bfetch
Cdownload
Dget_dataset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'download' or 'fetch' which are not valid TensorFlow dataset methods.
Trying to call a method that does not exist in tf.keras.datasets.cifar10.
2fill in blank
medium

Complete the code to normalize CIFAR-10 images to the range 0-1.

Computer Vision
cifar_train_images = cifar_train[0] / [1]
Drag options to blanks, or click blank then click option'
A255
B100
C1
D256
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing by 100 or 256 which does not correctly normalize pixel values.
Not dividing at all, leaving pixel values in 0-255 range.
3fill in blank
hard

Fix the error in this code to load ImageNet dataset using TensorFlow Datasets.

Computer Vision
import tensorflow_datasets as tfds
imagenet_data = tfds.load('imagenet_v2', split=[1])
Drag options to blanks, or click blank then click option'
A'train[:80%]'
B'validation'
C'train'
D'test'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' or 'test' which may not exist or are not the validation split.
Using slicing syntax like 'train[:80%]' which is invalid here.
4fill in blank
hard

Fill both blanks to create a dictionary of image shapes and labels from CIFAR-10 training data.

Computer Vision
image_info = {i: {'shape': cifar_train[0][i].[1], 'label': cifar_train[1][i][[2]]} for i in range(5)}
Drag options to blanks, or click blank then click option'
Ashape
B0
C1
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'size' instead of 'shape' for image dimensions.
Using label index 1 which is out of range.
5fill in blank
hard

Fill all three blanks to filter CIFAR-10 images with width greater than 30 and create a dictionary of their labels and shapes.

Computer Vision
filtered = {i: {'label': cifar_train[1][i][0], 'shape': cifar_train[0][i].[1] for i in range(len(cifar_train[0])) if cifar_train[0][i].shape[[2]] [3] 30}
Drag options to blanks, or click blank then click option'
Ashape
B1
C>
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 0 which is height, not width.
Using '<' instead of '>' for filtering.