Skip to content

Variable-size image to convolutional layer #1920

@shodutta92

Description

@shodutta92

Hi, I'm trying to run variable-sized images through convolutional layers but I'm getting an error about the row sizes not matching. From what i understand in this post, I should be able to use a snippet like

from keras.models import Sequential
from keras.layers import Convolution2D
import numpy as np

m = Sequential()
m.add(Convolution2D(8, 3, 3, input_shape=(1, 10, 10)))
m.compile(loss="mae", optimizer="sgd")
c = m.predict(np.random.rand(1, 1, 10, 10))
c = m.predict(np.random.rand(1, 1, 20, 20))

However, the second predict statement throws an error:

ValueError: The hardcoded shape for the number of rows in the image (10) isn't the run time shape (20).

Is there some way to use this in an input-shape independent fashion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions