title: ValueError:could not broadcast input array from shape (1221,) into shape (1221,7)
body: <p>I am working on my project titled 'Prediction of Stock price using Stacked LSTM', but I am getting this error &quot;ValueError: could not broadcast input array from shape (1221,) into shape (1221,7)&quot;, in the line</p>
  <blockquote>
  <p>trainPredictPlot[look_back:len(train_predict)+look_back, :] = train_predict</p>
  </blockquote>
  <p>My code is:</p>
  <pre><code>import tensorflow as tf
  from tensorflow.keras.models import load_model
  from tensorflow.keras.models import Sequential
  from tensorflow.keras.layers import Dense, LSTM, Dropout
  lstm_model = Sequential()
  lstm_model.add(LSTM(50, return_sequences = True, input_shape = (100, 1)))
  lstm_model.add(LSTM(50, return_sequences = True))
  lstm_model.add(LSTM(50))
  lstm_model.add(Dense(1))
  lstm_model.compile(loss = 'mean_squared_error', optimizer = 'adam')
  
  lstm_model.summary()
  
  lstm_model.fit(X_train, Y_train, validation_data = (X_test, Y_test), epochs = 100, batch_size = 64, verbose = 1)
  
  
  train_predict = lstm_model.predict(X_train)
  test_predict = lstm_model.predict(X_test)
  train_predict.shape
  test_predict.shape
  
  train_predict_dataset_like = np.zeros(shape=(len(train_predict), 7) )
  # put the predicted values in the right field
  train_predict_dataset_like[:,0] = train_predict[:,0]
  # inverse transform and then select the right field
  train_predict = scaler.inverse_transform(train_predict_dataset_like)[:,0]
  
  test_predict_dataset_like = np.zeros(shape=(len(test_predict), 7) )
  # put the predicted values in the right field
  test_predict_dataset_like[:,0] = test_predict[:,0]
  # inverse transform and then select the right field
  test_predict = scaler.inverse_transform(test_predict_dataset_like)[:,0]
  import math
  
  from sklearn.metrics import mean_squared_error
  math.sqrt(mean_squared_error(Y_train, train_predict))
  
  math.sqrt(mean_squared_error(Y_test, test_predict))
  
  ### Plotting 
  # shift train predictions for plotting
  look_back=100
  trainPredictPlot = numpy.empty_like(data)
  trainPredictPlot[:, :] = numpy.nan
  
  ##### This is where the error takes place ####
  trainPredictPlot[look_back:len(train_predict)+look_back, :] = train_predict
  
  # shift test predictions for plotting
  testPredictPlot = numpy.empty_like(data)
  testPredictPlot[:, :] = numpy.nan
  
  ##### This is where the error takes place ####
  testPredictPlot[len(train_predict)+(look_back*2)+1:len(data)-1, :] = test_predict
  
  
  # plot baseline and predictions
  plt.plot(scaler.inverse_transform(data))
  plt.plot(trainPredictPlot)
  plt.plot(testPredictPlot)
  plt.show()
  </code></pre>
  <p>The shape of <code>train_predict</code> and <code>test_predict</code> are (1221, 1) &amp; (1221, 1) respectively.</p>