Natural Language Processing · Advanced level

Advanced level · Module 3 of 10 · 13 guided hours

Long Short-Term Memory Networks for Text

LSTM networks for language: gates and memory cells, bidirectional and stacked LSTMs, packed sequences, regularisation, and an LSTM text classifier compared with earlier models.

Learning objectives

  • Explain the LSTM gates and memory cell
  • Build bidirectional LSTM classifiers with packed sequences
  • Regularise and evaluate LSTM text models

Topics

  • forget, input and output gates
  • nn.LSTM and GRU
  • bidirectional and stacked LSTMs
  • pack_padded_sequence
  • dropout and gradient clipping
  • LSTM classifiers versus baselines

Lessons

  1. Lesson 1 How LSTMs Remember

    Learners examine how the forget, input and output gates control a memory cell, and how this lets gradients flow across longer texts than a plain RNN can handle.

    cell stateforget gateinput gateoutput gateGRU

  2. Lesson 2 Bidirectional LSTM Text Classifiers

    Learners build a bidirectional LSTM classifier with packed sequences so that padding does not affect results, and initialise it with pretrained or Word2Vec embeddings.

    bidirectional=Truepack_padded_sequenceconcatenated final statespretrained embedding initialisationfreezing layers

  3. Lesson 3 Regularising and Evaluating LSTM Models

    Learners control overfitting with dropout, weight decay, early stopping and gradient clipping, and evaluate the LSTM against all earlier models.

    dropoutweight decayearly stoppingclip_grad_norm_model comparison table

Practical activity

Train a regularised bidirectional LSTM for the news task and complete the three-way comparison with TF-IDF and EmbeddingBag models.

Expected outcomes

  • Practical LSTM skills for text
  • Evidence-based architecture choice

Assessment

Notebook review (70%) and the comparison recommendation (30%).

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.