marcellacornia / mlnet

A Deep Multi-Level Network for Saliency Prediction. ICPR 2016
MIT License
94 stars 37 forks source link

Problem of input shape #10

Closed wuzhe71 closed 6 years ago

wuzhe71 commented 6 years ago

I install Theano0.9.0 and keras1.1.0 and test the code in my datasets according to your comand. But it errors in Exception: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 1, 60, 256), (None, 1, 60, 512), (None, 1, 60, 512)]

So i modify the input input_ml_net = Input(shape=(3, img_rows, img_cols)) to input_ml_net = Input(shape=(img_rows, img_cols, 3)), and convertconcat_axis=1 to concat_axis=3, the network is correctly constructed:

((None, 480, 640, 3), (None, 480, 640, 3))
((None, 480, 640, 3), (None, 480, 640, 64))
((None, 480, 640, 64), (None, 480, 640, 64))
((None, 480, 640, 64), (None, 240, 320, 64))
((None, 240, 320, 64), (None, 240, 320, 128))
((None, 240, 320, 128), (None, 240, 320, 128))
((None, 240, 320, 128), (None, 120, 160, 128))
((None, 120, 160, 128), (None, 120, 160, 256))
((None, 120, 160, 256), (None, 120, 160, 256))
((None, 120, 160, 256), (None, 120, 160, 256))
((None, 120, 160, 256), (None, 60, 80, 256))
((None, 60, 80, 256), (None, 60, 80, 512))
((None, 60, 80, 512), (None, 60, 80, 512))
((None, 60, 80, 512), (None, 60, 80, 512))
((None, 60, 80, 512), (None, 60, 80, 512))
((None, 60, 80, 512), (None, 60, 80, 512))
((None, 60, 80, 512), (None, 60, 80, 512))
((None, 60, 80, 512), (None, 60, 80, 512))
([(None, 60, 80, 256), (None, 60, 80, 512), (None, 60, 80, 512)], (None, 60, 80, 1280))
((None, 60, 80, 1280), (None, 60, 80, 1280))
((None, 60, 80, 1280), (None, 60, 80, 64))
((None, 60, 80, 64), (None, 60, 80, 1))
((None, 60, 80, 1), (None, 60, 80, 1))
((None, 60, 80, 1), (None, 60, 80, 1))

But it errors in: Exception: Error when checking : expected input_1 to have shape (None, 480, 640, 3) but got array with shape (1, 3, 480, 640)

Then i comment outims = ims.transpose((0, 3, 1, 2)) in preprocess_images, and it errors in :

ValueError: Input dimension mis-match. (input[1].shape[1] = %lli, input[%i].shape[%i] = %lli)
Apply node that caused the error: Elemwise{Composite{(i0 * ((i1 + i2) + Abs((i1 + i2))))}}[(0, 1)](TensorConstant{(1, 1, 1, 1) of 0.5}, CorrMM{half, (1, 1), (1, 1)}.0, InplaceDimShuffle{x,0,x,x}.0)

So how to make the code work well?

Best Regards

marcellacornia commented 6 years ago

Hi @inkfish2015, thanks for downloading our code.

The correct input shape is Input(shape=(3, img_rows, img_cols)). Have you set the dim ordering to "th" in the keras.json file?

wuzhe71 commented 6 years ago

Thanks, i set the dim ordering and reinstall theano and keras and solve the problem.