I've a list of data which is so called 3D array. Each of 10350 rows contains a 2D matrix with size of 150x16 (elements are float) (x_train). Corresponding training data for this huge array a linear array with size of 10350 integer which can be either 0 or 1 (y_train).

I used different methods to estimate the test_data. None of them worked with such type of array.

from matplotlib import pyplot as plt

from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from sklearn.preprocessing import MinMaxScaler

min_max_scaler = MinMaxScaler()

train_data_set = np.load("files/samples/A08_Block_sample.npy")
test_data_set = np.load("files/samples/A10_BLOCK_sample.npy")

x_train = []
y_train = []

for i in range(len(train_data_set)):

   num_units = 4
   activation_function = 'sigmoid'
   optimizer = 'adam'
   loss_function = 'mean_squared_error'
   batch_size = 5
   num_epochs = 100

   regressor = Sequential()

   regressor.add(LSTM(units=num_units, activation=activation_function, input_shape=(10403, 16, 150)))


   regressor.compile(optimizer=optimizer, loss=loss_function)

   regressor.fit(x_train, y_train, batch_size=batch_size, epochs=num_epochs)

   inputs_x = []
   inputs_y = []
   for i in range(len(test_data_set)):

   predicted_price = regressor.predict(inputs_x)

The library that I'm using is Keras. I'm new at data science, any suggestion will be welcome for me.

  • $\begingroup$ Many things could be going wrong, but one thing that stands out is that you're using mean squared error as your loss function. For classification tasks, you should be using the binary cross entropy (called binary_crossentropy in Keras) $\endgroup$ Sep 27, 2018 at 2:58

1 Answer 1


Change first layer with

regressor.add(LSTM(units=num_units, input_shape=(x_train.shape[1],x_train.shape[2])))

You need to have 2 numbers as input shape.

Hope will help you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.