Issue
Hi I have images with the size of 160*120 (meaning 160 is the width and 120 is the height) I want to train a network with this data set in keras and no resizing.. I think in keras instead of writing
model.add(Conv2D(....,input_shape = (160,120,1) , ....)
I should write
model.add(Conv2D(....,input_shape = (120,160,1) , ....)
so does input shape in keras first take height and then width?though with both input sizes the training starts and no error pops up indicating that input size doesn't match... One other note is that after training the network with
model.add(Conv2D(....,input_shape = (120,160,1) , ....)
as my input shape still in summary it says Output Shape = (None,159,119,3) after the first convolution layer with filter size=2*2 and number of filters being 3...I thought it should be Output Shape = (None,119,159,3) I am really confused can anyone help?
Solution
From the TensorFlow docs:
Input shape: 4+D tensor with shape: batch_shape + (channels, rows, cols) if data_format='channels_first' or 4+D tensor with shape: batch_shape + (rows, cols, channels) if data_format='channels_last'.
A 160 pixel width means 160 columns and a 120 pixel height means 120 rows, so the correct Tensor input_shape
would be (120, 160, 1)
for your 1-channel image.
Using 3 filters in your Conv2D
layer means that three individual kernels convolve (slide) over your input image. With a 2x2 kernel size, it means that your Conv2D
layer will produce 3 outputs of size (input_width-1, input_height-1)
, which indeed is (159, 119, 3)
in your case.
(source: https://www.machinecurve.com/index.php/2021/11/07/introduction-to-isotropic-architectures-in-computer-vision/)
Answered By - webchitect
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.