# Using LSTM's on Multivariate Input AND Multivariate Output

I have a very small dataset, only about 40 rows, that has historical usage data for a few categories (roughly 20). I strongly suspect that these categories are dependent in a partial-zero-sum-game fashion: if the usage of one category goes up, I'm expecting that of another to go down. My goal is to predict the next row of all categories.

I've looked at this post, but it's not predicting multiple variables. I also looked at this post, but it's still univariate output (albeit multiple time steps) and multivariate input. So far, I've been basing my approach on the typical LSTM post here at machinelearningmastery, but it's also a single-output-variable example, and a number of the functions used, such as scaler.inverse_transform don't appear to broadcast very well. I'm even having difficulties trying to scale back my full example to match his!

Any tips for scaling LSTM's up to multivariate output? Can the keras LSTM do this natively? If so, how would the code change?

You can simply change the number of units at the last layer if you want to predict multiple outputs (or just said differently, one output with multiple features). For example from the link you shared, you can change the units of the Dense layer:

model = Sequential()

• I'm getting an error in the next line: history = model.fit(train_X, train_y, epochs=100, batch_size=72, validation_data=(test_X, test_y), verbose=2, shuffle=False). The error is: ValueError: Error when checking target: expected dense_1 to have shape (17,) but got array with shape (1,). Any ideas? – Adrian Keister Jan 19 '19 at 20:44