Training and validating the results

The next step will be to prepare a training and validation dataset. Our dataset has over 9,000 images and I have made a decision to run the training on the 8000 and leave the rest for validation. I have also defined batch_size for training to be as large as the validation dataset. You might need to adjust it to 100, 250, or 500 if you don't have enough resources:

train_indices = 1:8000;valid_indices = 8000:length(images);batch_size = length(valid_indices);

Next, we will create a custom iterator. It will be a for loop that will randomly choose images for training and validate them on our validation dataset:

for i = 1:30    println(i, " - ", i+batch_size-1); train_indices_batch = sample(train_indices, batch_size, ...

Get Hands-On Computer Vision with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.