print("train_y shape={}format(train_y shape)print("test_x shape={}format(test_x shape)print("test_y shape={}format(test_y shape)data split complete train_x shape=( train_y shape=( test_x shape=( test_y shape=( having prepared the datasetslet we'll now move onto setting up the rnn network since we are planning on generating sequence as output as opposed to single output in the previous casewe need to tweak our network architecture the requirement in this case is to apply similar transformations/processing for every time step and be able to get output for every input timestamp rather than waiting for the whole sequence to be processed to enable such scenarioskeras provides wrapper over dense layers called timedistributed this wrapper applies the same task to every time step and provides hooks to get output after each such time step we use timedistributed wrapper over dense layer to get output from each of the time steps being processed the following snippet showcases get_seq_model(function to generate the required model def get_seq_model(hidden_units= ,input_shape=( , ),verbose=false)create and fit the lstm network model sequential(input shape timesteps*features model add(lstm(input_shape=input_shapeunits hidden_unitsreturn_sequences=true )timedistributeddense uses the processing for all time steps model add(timedistributed(dense( ))start time time(model compile(loss="mse"optimizer="rmsprop"if verboseprint("compilation time "time time(startprint(model summary()return model this function returns single hidden layer rnn network with four lstm units and timedistributed dense output layer we again use mean squared error as our loss function ##note timedistributed is powerful yet tricky utility available through keras you may explore more on this at com/questions/ /the-difference-between-dense-and-timedistributeddense-of-keras