Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input of CAReduce{maximum} has zero-size on axis 2 #15

Open
XiminLin opened this issue Sep 13, 2017 · 0 comments
Open

Input of CAReduce{maximum} has zero-size on axis 2 #15

XiminLin opened this issue Sep 13, 2017 · 0 comments

Comments

@XiminLin
Copy link

XiminLin commented Sep 13, 2017

Hi, I was using the SpatialPyramidPooling you wrote. Excellent works and Thanks.

But when I run the model with SpatialPyramidPooling, first time the shape including number sample is (32, 19567, 50), and it goes well. The second batch has shape (32, 7010, 50). And this is where the problem occurs.

--------- Error Message ---------

Traceback (most recent call last):
      File "all_models_v2.py", line 755, in <module>
        main()
      File "all_models_v2.py", line 700, in main
       model.fit_generator( generator=train_data_gen, steps_per_epoch=TRAIN_LENGTH // 
BATCH_SIZE, epochs = 10, callbacks=[early_stopper], validation_data = val_data_gen, 
validation_steps = VAL_LENGTH // BATCH_SIZE)
      File "/home/k/shankai/app/anaconda2/lib/python2.7/site-
packages/keras/legacy/interfaces.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "/home/k/shankai/app/anaconda2/lib/python2.7/site-packages/keras/engine/training.py", line 1902, in fit_generator
    class_weight=class_weight)
  File "/home/k/shankai/app/anaconda2/lib/python2.7/site-packages/keras/engine/training.py", line 1642, in train_on_batch
    outputs = self.train_function(ins)
  File "/home/k/shankai/app/anaconda2/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 1196, in __call__
    return self.function(*inputs)
  File "/home/k/shankai/app/anaconda2/lib/python2.7/site-packages/theano/compile/function_module.py", line 898, in __call__
    storage_map=getattr(self.fn, 'storage_map', None))
  File "/home/k/shankai/app/anaconda2/lib/python2.7/site-packages/theano/gof/link.py", line 325, in raise_with_op
    reraise(exc_type, exc_value, exc_trace)
  File "/home/k/shankai/app/anaconda2/lib/python2.7/site-packages/theano/compile/function_module.py", line 884, in __call__
    self.fn() if output_subset is None else\
ValueError: Input of CAReduce{maximum} has zero-size on axis 2
Apply node that caused the error: Reduce{maximum}{1, 2}(Reshape{4}.0)
Toposort index: 666
Inputs types: [TensorType(float32, 4D)]
Inputs shapes: [(32, 19564, 0, 1)]
Inputs strides: [(234768, 4, 4, 4)]
Inputs values: [array([], shape=(32, 19564, 0, 1), dtype=float32)]
Outputs clients: [[Join(TensorConstant{1}, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max, max), InplaceDimShuffle{0,x,x,1}(max)]]

I am using Theano backend of Keras. Ubuntu, since there is no reshape in my model except maybe in SpatialPyramidPooling. Following is my model:

main_input = Input(shape=input_shape, dtype = "float32", name = "main_input")

conv11 = Conv2D(1, (3,50), activation = "relu", data_format="channels_last")(main_input)
conv11 = BatchNormalization()(conv11)

conv12 = Conv2D(1, (4,50), activation = "relu", data_format="channels_last")(main_input)
conv12 = BatchNormalization()(conv12)

conv13 = Conv2D(1, (5,50), activation = "relu", data_format="channels_last")(main_input)
conv13 = BatchNormalization()(conv13)

conv1 = Concatenate(1)([conv11, conv12, conv13])

if spp_shape is not None:
	conv1 = SpatialPyramidPooling(spp_shape)(conv1)
	output = Dense(NUM_CLASS, input_shape = (50,), activation = "softmax")(conv1)
else:
	conv1 = Flatten()(conv1)
	output = Dense(NUM_CLASS, input_shape = (2991,), activation = "softmax" )(conv1)

model = Model(inputs=[main_input], outputs=[output] )

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant