#This function takes as parameter the path of a single batch as a string, and returns a matrix data of size (batch_size x data_size) and a a vector labels of size batch_size.
withopen(batch_path,'rb')asbp:
data_dict=load_pickle(bp)
data=data_dict['data']
labels=data_dict['labels']
data=data.reshape(10000,3072)
data=data.astype('f')#data must be np.float32 array.
labels=np.array(labels,dtype='i')#labels must be np.int64 array.
returndata,labels
defread_cifar(directory_path):
#This function takes as parameter the path of the directory containing the six batches and returns a matrix data a vector lables of size batch_size
#This function splits the dataset into a training set and a test set
#It takes as parameter data and labels, two arrays that have the same size in the first dimension. And a split, a float between 0 and 1 which determines the split factor of the training set with respect to the test set.