Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Machine Learning by (19k points)

Can the Keras deal with input images with different sizes? For example, in the fully convolutional neural network, the input images can have any size. However, we need to specify the input shape when we create a network by Keras. Therefore, how can we use Keras to deal with different input size without resizing the input images to the same size? Thanks for any help.

1 Answer

0 votes
by (33.1k points)

You can input images of different sizes to keras easily, but some changes to code is required for that: .

You can change your input shape to shape=(n_channels, None, None). 

Here n_channels is the number of channels in your input image.

If you are using TensorFlow, you might have to change it to (None,None,n_channels)

You should use:

input_shape=(1, None, None)

For example, using keras functional API, your input layer would be:

For an RGB dataset

inp = Input(shape=(3,None,None))

For a Grayscale dataset

inp = Input(shape=(1,None,None))

Hope this answer helps.

Browse Categories

...