how to reshape array to predict with LSTM

Question:

I made an LSTM model based on this tutorial where the model input batch shape is:

print(config["layers"][0]["config"]["batch_input_shape"])

returns:

(None, 1, 96)

Can someone give me a tip on how change my testing data to this array shape to match the model input batch size?

testday = read_csv('./data.csv', index_col=[0], parse_dates=True)
testday_scaled = scaler.fit_transform(testday.values)

print(testday_scaled.shape)

returns

(96, 1)
Asked By: bbartling

||

Answers:

IIUC, You need to use numpy.swapaxes and then add None to the first dimension.

import numpy as np
testday_scaled = np.swapaxes(testday_scaled, 0, 1)
testday_scaled = testday_scaled[None, ...]
Answered By: I'mahdi
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.