<jupyter_start><jupyter_text>LSTM in Keras<jupyter_code>from keras.layers import Input, LSTM, Bidirectional
from keras.models import Model<jupyter_output><empty_output><jupyter_text>Many-to-One **Standard LSTM**    in(timesteps,features) -> LSTM(units) -> out(units)<jupyter_code>timesteps = 11
features = 3
units = 5

x = Input(shape=(timesteps, features))
a = LSTM(units, return_sequences=False)(x)
Model(x, a).summary()<jupyter_output>_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_1 (InputLayer)         (None, 11, 3)             0         
_________________________________________________________________
lstm_1 (LSTM)                (None, 5)                 180       
=================================================================
Total params: 180
Trainable params: 180
Non-trainable params: 0
_________________________________________________________________<jupyter_text>**Bidirectional LSTM**    in(timesteps,features) -> LSTM(units) -> out(2 * units)<jupyter_code>timesteps = 11
features = 3
units = 5

x = Input(shape=(timesteps, features))
a = Bidirectional(LSTM(units, return_sequences=False))(x)
Model(x, a).summary()<jupyter_output>_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_2 (InputLayer)         (None, 11, 3)             0         
_________________________________________________________________
bidirectional_1 (Bidirection (None, 10)                360       
=================================================================
Total params: 360
Trainable params: 360
Non-trainable params: 0
_________________________________________________________________<jupyter_text>Many-to-Many **Standard LSTM**    in(timesteps,features) -> LSTM(units) -> out(timesteps,units)<jupyter_code>timesteps = 11
features = 3
lstm_units = 5

x = Input(shape=(timesteps, features))
a = LSTM(lstm_units, return_sequences=True)(x)
Model(x, a).summary()<jupyter_output>_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_3 (InputLayer)         (None, 11, 3)             0         
_________________________________________________________________
lstm_3 (LSTM)                (None, 11, 5)             180       
=================================================================
Total params: 180
Trainable params: 180
Non-trainable params: 0
_________________________________________________________________<jupyter_text>**Bidirectional LSTM**    in(timesteps,features) -> LSTM(units) -> out(timesteps, 2 * units)<jupyter_code>timesteps = 11
features = 3
lstm_units = 5

x = Input(shape=(timesteps, features))
a = Bidirectional(LSTM(lstm_units, return_sequences=True))(x)
Model(x, a).summary()<jupyter_output>_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_4 (InputLayer)         (None, 11, 3)             0         
_________________________________________________________________
bidirectional_2 (Bidirection (None, 11, 10)            360       
=================================================================
Total params: 360
Trainable params: 360
Non-trainable params: 0
_________________________________________________________________
{'fraction_non_alphanumeric': 0.2159956474428727, 'fraction_numerical': 0.025027203482045703, 'mean_word_length': 4.8272583201267825, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '149071', 'license': 'MIT', 'n_tokens_mistral': 953, 'n_tokens_neox': 827, 'n_words': 190, 'path': 'notebooks/NeuralNetworks/lstm.ipynb', 'repo_name': 'cedrou/ml-notebooks', 'size': '3676'}