Complete the code to load the CIFAR-10 dataset using TensorFlow.
import tensorflow as tf (cifar_train, cifar_test) = tf.keras.datasets.cifar10.[1]()
The correct function to load CIFAR-10 dataset in TensorFlow is load_data(). It returns training and test sets.
Complete the code to normalize CIFAR-10 images to the range 0-1.
cifar_train_images = cifar_train[0] / [1]
Image pixel values range from 0 to 255. Dividing by 255 scales them to 0-1.
Fix the error in this code to load ImageNet dataset using TensorFlow Datasets.
import tensorflow_datasets as tfds imagenet_data = tfds.load('imagenet_v2', split=[1])
The ImageNet dataset split for validation is named 'validation'. Using 'validation' loads the validation set correctly.
Fill both blanks to create a dictionary of image shapes and labels from CIFAR-10 training data.
image_info = {i: {'shape': cifar_train[0][i].[1], 'label': cifar_train[1][i][[2]]} for i in range(5)}Each image has a shape attribute for its dimensions. Labels are stored as arrays, so index 0 accesses the label value.
Fill all three blanks to filter CIFAR-10 images with width greater than 30 and create a dictionary of their labels and shapes.
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}The image shape attribute gives dimensions. Index 1 corresponds to width. We filter images with width greater than 30 using '>'.