0

With Keras, I defined,

conv = Convolution2D(num_filters, ws, ws)(x),

where I have the shape of x be (1, ?, 10, 1)

And I met the problem with

TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

Since the convolutional weight matrices applied on each window of the 2D image share parameters, it is valid at least for me to do it without knowing the true dimension of the image.

xxx222
  • 2,980
  • 5
  • 34
  • 53

1 Answers1

0

If you want to process input of arbitrary size in your CNN define first layer as follows:

Convolution2D(num_filters, ws, ws, input_shape=(nb_channels, None, None))

Note that it takes much longer time to train a network with variable input size compared to fixed. See my question here.

Community
  • 1
  • 1
Sergii Gryshkevych
  • 4,029
  • 1
  • 25
  • 42