Input changing row count matrices in an MLP I want to input a numpy 2d array into MLP but I have an array of 50395 rows that contains many 2d array of shape (x, 129). x because some matrices have different row numbers. Here is an example :
train['spec'].shape
&gt;&gt;(50395,)
train['spec'][0].shape
&gt;&gt;(41, 129)
train['spec'][5].shape
&gt;&gt;(71, 129)

Here an snippet of my code :
X_train = train['spec'].values;     X_valid = valid['spec'].values
y_train = train['label'].values;    y_valid = valid['label'].values
model.add(Dense(12, input_shape=(50395, ), activation='relu'));
model.fit(X_train, y_train, validation_data=(X_valid, y_valid), epochs=500, batch_size=1);

I get this error on last line (model.fit) :
ValueError: Error when checking input: expected dense_54_input to have shape (50395,) but got array with shape (1,)
How to fix this problem so that the network can take as input all 50395 matrices of shape (x, 129)?
First, I made the matrices (x, 129) to have the same shape by padding in with the rows filled with zeros.
Second, I transformed my large matrices into dimension 3 by the following process:
train = list(train_df['spec'])
np.array(train).shape
&gt;&gt;&gt; (50395, 71, 129)


X_train = list(train['spec']);     X_valid = list(valid['spec'])
y_train = train['label'].values;    y_valid = valid['label'].values
model.add(Dense(12, input_shape=(50395, 71, 129), activation='relu'));
model.fit(np.array(X_train), y_train, validation_data=(np.array(X_valid), y_valid), epochs=500, batch_size=1);