O'Reilly logo

Deep Learning By Example by Ahmed Menshawy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data analysis and preprocessing

We need to analyze the dataset and do some basic preprocessing. So, let's start off by defining some helper functions that will enable us to load a specific batch from the five batches that we have and print some analysis about this batch and its samples:

# Defining a helper function for loading a batch of imagesdef load_batch(cifar10_dataset_dir_path, batch_num):        with open(cifar10_dataset_dir_path + '/data_batch_' + str(batch_num), mode='rb') as file:        batch = pickle.load(file, encoding='latin1')    input_features = batch['data'].reshape((len(batch['data']), 3, 32, 32)).transpose(0, 2, 3, 1)    target_labels = batch['labels']    return input_features, target_labels

Then, we define a function that can help us display ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required