I came across the following statement:
convnet = input_data(shape=[None,img_size,img_size,1], name='input')
I tried looking for a description, but couldn't find a clear explanation.
My main question here is what is the function input_data
mainly doing? Is it like a place holder for our input data?
Regarding the shape, what is None
at the beginning, and 1
at the end?
Thanks.
The input_data
is a layer that will be used as the input layer to your network. Before adding any of the usual layer in your sequential model, you need to specify how your input looks like. Like for example in the mnist data set where you have 784 array representing 28x28 images.
In your example the network wants an input with the shape (None, img_size,img_size,1] meaning in human language:
None - many or a number of or how many images of
img_size X img_size - dimensions of the image
1 - with one color channel
If the mnist dataset would be in full RGB color the input data would be of shape (None, 28, 28, 3)
Usually the None you could think of it as the batch_size.
To be even more explicit, if you would have a batch_size of 1 then you would need as input, in our mnist RGB example, three 28x28 matrixes, one representing the R pixels, another the G pixels and lastly one for the B pixels of the image. This is just one entry. In this case the None value would be 1, but usually it is whatever you decide the batch_size is. You get the picture from here.
Hope it clears things out.
Cheers,
Gabriel
De Santa answer is right: input_data is a placeholder for input features. The array you mention holds first None (always), then IMG width and height (seems the image is squared since width=height) and channels (in this case is 1; ex.: in case of RGB you would get 3 channels). This way the net gets to know the dimensions of input features.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With