<jupyter_start><jupyter_text>CITS5508 labsheet 5Sample code showing how to read the CIFAR-10 data. Only cells 1 and 2 are needed. **Note: For the code to work, all the data batch files should be in the same directory with this Notebook file.**This is only an example. Students should put in their own markdown cells. Rather than looking at the code in the file **data_loader.py**, description about the `DataLoader` class in the file can be viewed using **pydoc**. Try typing the following command in a terminal window (assuming that *data_loader.py* is in the current directory):&nbsp; &nbsp; pydoc data_loaderTo convert this file into **lab05-sample.py**, a Python script file, for running on **Kaya** (the UWA GPU computer), do the following:* If you are using Jupyter-lab, then select **File $>$ Export Notebook As... $>$ Executable Script $>$**. In the popped up window, select **Save File** and click the **OK** button.* If you are using **Jupyter-notebook**, then select **File $>$ Download as $>$ Python (.py)**. Note that the option **Python (.py)** might be hidden. You would need to scroll down the list to see it. In the popped up window, select **Save File** and click the **OK** button.**Author: <NAME>****Date: April 2021**  Step 1: Import the `DataLoader` class<jupyter_code>from data_loader import DataLoader<jupyter_output><empty_output><jupyter_text>Step 2: Call the `load_batch` function<jupyter_code># According to the CIFAR-10 website, the training set is split into five batches
# stored in fives files. Each colour image has dimensions equal to 32 x 32 x 3. There
# are 10 classes.
image_width, image_height, image_Nchannels = 32, 32, 3
class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer',
               'dog', 'frog', 'horse', 'ship', 'truck']

# The default values of all the arguments of the load_batch function have been
# set for the CIFAR-10 dataset.
X_train, y_train = DataLoader.load_batch('data_batch')
X_test, y_test = DataLoader.load_batch('test_batch', Nbatches=1)<jupyter_output><empty_output><jupyter_text>Step 3. A quick inspection of the outputs from the `load_batch` function<jupyter_code># You need to split the training set to form a validation set. The original
# training set would become smaller.
print('X_test.shape =', X_test.shape, 'data type:', X_test.dtype)
print('y_test.shape =', y_test.shape, 'data type:', y_test.dtype)<jupyter_output>X_test.shape = (10000, 32, 32, 3) data type: float32
y_test.shape = (10000,) data type: uint8
{'fraction_non_alphanumeric': 0.11102204408817636, 'fraction_numerical': 0.02124248496993988, 'mean_word_length': 5.132678132678133, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '255210', 'license': 'Apache-2.0', 'n_tokens_mistral': 796, 'n_tokens_neox': 738, 'n_words': 329, 'path': 'labs/lab05/lab05.ipynb', 'repo_name': 'Kaiqi-Liang/CITS5508', 'size': '2497'}