How to make LSTM Multivariate?

Hi Guys,

I am new to PyTorch and I need help. I was trying to use the sample code here:

it works well, but when I tried to add more input features I got Error in the testing section for the following lines:

data_predict = sc.inverse_transform(data_predict)
dataY_plot = sc.inverse_transform(dataY_plot)

The error says “non-broadcastable output operand with shape (110,1) doesn’t match the broadcast shape”

so the model works well, but I can’t retrieve the original value of Y. So what else Should I modify in the code? I modified “input_size” in training section and added so following line in Data loading section:

y = (y[:,0]).reshape(y[:,0].shape[0],1) 

and finally

training_set = df.iloc[:,1:3].values

Thanks in advance

Hy can you compare the output shape of your and the data_predict which your trying

Thanks Usama for your reply,

the shape of data_predict and it is (110,1), so apparently it contains only the target values, while the orginal data before min_max_scaler is (110,4) target + 3 features.

Hy @Sam_badie, Your error is quite clear, min_max_scaler will only convert array that have the same shape say (no_samples,4), which was used to fit the min_max_scaler object.