In the two previous tasks, images were available directly from the MLDatasets package. Unfortunately, in real-world scenarios, images are stored on a disk.
Despite the large number of records in the training dataset, we will put them all into memory. To make the process more efficient, we will be resizing the images to 32x32 pixels and converting them to floats. This is shown in the following code:
files = readdir(IMAGES_PATH);data_x = zeros((32, 32, 3, size(files, 1)));data_y = zeros(size(files, 1));for idx = 1:size(files, 1) file_name = joinpath(IMAGES_PATH, files[idx]) if endswith(file_name, ".jpg") img = imresize(load(file_name), (32, 32)) data_x[:, :, :, idx] = permuteddimsview(Float16.(channelview(img)), ...