sequence modeling in the previous section we modeled our time series like regression use case in essencethe problem formulation though utilized past window to forecastit did not use the time step information in this sectionwe will solve the same stock prediction problem using lstms by modeling it as sequence for the hands-on examples in this sectionyou can refer to the jupyter notebook notebook_stock_prediction_ sequence_modeling_lstm ipynb for the necessary code snippets and examples recurrent neural networks are naturally suited for sequence modeling tasks like machine translationspeech recognition and so on rnns utilize memory (unlike normal feed forward neural networksto keep track of context and utilize the same to generate outputs in general feed forward neural networks assume inputs are independent of each other this independence may not hold in many scenarios (such as time series datarnns apply same transformations to each element of the sequencewith outcomes being dependent upon previous values in case of our stock price time serieswe would like to model it now as sequence where value at each time step is function of previous values unlike the regression-like modelinghere we do not divide the time series into windows of fixed sizesrather we would utilize the lstms to learn from the data and determine which past values to utilize for forecasting to do sowe need to perform certain tweaks to the way we processed our data in the previous case and also how we built our rnn in the previous sectionwe utilized the ( , ,fformat as input in the current settingthe format remain the same with the following changes (number of sequences)this will be set to since we are dealing with only one stock' price information (length of sequence)this will be set to total number of days worth of price information we have with us here we use the whole series as one big sequence (features per timestamp)this is again as we are only dealing with closing stock value per timestamp talking about the outputin the previous section we had one output for every window/sequence in consideration while modeling our data as sequence/time series we expect our output to be sequence as well thusthe output is also tensor following the same format as the input tensor we write small utility function get_seq_train_test(to help us scale and generate train and test datasets out of our time series we use - split in this case we then use numpy to reshape our time series into tensors the following snippet utilizes the get_seq_train_test(function to do the same in [ ]train,test,scaler get_seq_train_test(sp_close_seriesscaling=truetrain_size=train_percenttrain np reshape(train,( ,train shape[ ], )test np reshape(test,( ,test shape[ ], )train_x train[:,:- ,:train_y train[:, :,:test_x test[:,:- ,:test_y test[:, :,:print("data split complete"print("train_x shape={}format(train_x shape)