Julia and MXNet: using DataProvider with images

Yesterday I spent my night setting up MXNet for solving Space Invaders. Initially, I thought it would not take me too long as I have been previously configuring data providers for MXNet in Julia, but it resulted in the opposite.

So, previously, whether I’ve been using a pre-trained network and sending a single image for classification, or I’ve been using 1-dimensional data I did not have any troubles.

This time I had to train my custom architecture on mini-batches of images, and this is where 4-dimensional arrays break. For some reason, MXNet just did not accept the value passed, and I had to find a solution.

It resulted in my defining an `mx.zeros` variable of a required dimension and then copying the content of my data to the newly created variable.

data_array  = mx.zeros((image_shape..., row_count...));
for idx = 1:row_count
    data_array[idx:idx] = reshape(images[idx], (image_shape..., 1...))
end

I haven’t updated the code in my GitHub yet. You will need to refer to the code example for the time being.

Julia and MXNet: using DataProvider with images

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s