Deep Neural neural: specify the input tensor

User 4531 | 4/8/2016, 8:25:20 PM

We can add image inside the deep neural network. But, how can we specify a tensor of dimension N as input of deep neural network ?

If I have a color image, how the input matrix is setup ? Thanks

Comments

User 940 | 4/9/2016, 6:16:19 PM

Hi @KevinNoe,

We only support image and vector inputs to our Deep Neural Networks(for now).

So you can formulate a tensor as 3-D with either 1, 3, or 4 channels by pretending it is an image. You can directly construct images as in the following how-to: https://github.com/dato-code/how-to/blob/master/frompilimage.py

Basically there is an internal vector and meta-data concerning the shape of the image.

You could also flatten your tensor into array type.

I can ask and see how expanding to tensor inputs fits on our roadmap.

Cheers! -Piotr


User 4531 | 4/12/2016, 7:08:39 AM

Dear Piotr,

Thank you. If I have a tensor of 45 x 45 x 3 size as numerical array, how can I transform into an image (png, jpg) ? (so, it can be recognized by Graphlab as input to be readable by sframe).


User 940 | 4/13/2016, 2:16:24 AM

So, assuming you have flattened the array in row-major order, you'd do something like this

`python format = {'JPG': 0, 'PNG': 1, 'RAW': 2, 'UNDEFINED': 3} formatenum = format['RAW'] imagedata_size = len(array)

img = gl.Image(imagedata=array, width=width, height=height, channels=channels, formatenum=formatenum, imagedatasize=imagedata_size) `

This will put it into a graphlab image type.

I hope this helps!

Cheers! -Piotr