My (Keras) model has two inputs of different shapes. The example on Keras website says it should work.
I defined the inputs as follows:
model1 = Model(inputs=[uii, vji], outputs=[decoded,decoded2, prod])
model1.summary()
Model: "model_10"
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_49 (InputLayer) [(None, 1682)] 0
__________________________________________________________________________________________________
input_51 (InputLayer) [(None, 943)] 0
__________________________________________________________________________________________________
But when fitting the model:
model1.fit([matrix, matrix.T], [matrix, matrix.T,matrix.reshape(-1)])
It produces the following error:
/tensorflow-2.1.0/python3.6/tensorflow_core/python/keras/engine/training_utils.py in check_array_lengths(inputs, targets, weights) 733 raise ValueError('All input arrays (x) should have ' 734 'the same number of samples. Got array shapes: ' + --> 735 str([x.shape for x in inputs])) 736 if len(set_y) > 1: 737 raise ValueError('All target arrays (y) should have '
ValueError: All input arrays (x) should have the same number of samples. Got array shapes: [(943, 1682), (1682, 943)]
Any solution to fix this kind of error? Thanks
I found the solution for this problem. It is the length of the inputs must be identical. So, I modify the input data to the same length, as well as the output.
For example: I set the length of both input to 1682 by pre-processing the data.
The shape of input1 can be (1682, 943)
The shape of input2 should be (1682, 1682)