deep learning for text and sequences output - output output_t activationw*input_t *state_t bostate input - figure output + state + input input + simple rnnunrolled over ime in this examplethe final output is tensor of shape (timestepsoutput_features)where each timestep is the output of the loop at time each timestep in the output tensor contains information about timesteps to in the input sequence--about the entire past for this reasonin many note casesyou don' need this full sequence of outputsyou just need the last output (output_t at the end of the loop)because it already contains information about the entire sequence recurrent layer in keras the process you just naively implemented in numpy corresponds to an actual keras layer--the simplernn layerfrom keras layers import simplernn there is one minor differencesimplernn processes batches of sequenceslike all other keras layersnot single sequence as in the numpy example this means it takes inputs of shape (batch_sizetimestepsinput_features)rather than (timestepsinput_featureslike all recurrent layers in kerassimplernn can be run in two different modesit can return either the full sequences of successive outputs for each timestep ( tensor of shape (batch_sizetimestepsoutput_features)or only the last output for each input sequence ( tensor of shape (batch_sizeoutput_features)these two modes are controlled by the return_sequences constructor argument let' look at an example that uses simplernn and returns only the output at the last timestepfrom keras models import sequential from keras layers import embeddingsimplernn model sequential(model add(embedding( )model add(simplernn( )model summary(licensed to