Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Oracle · OCI AI Foundations

CNN, RNN, and LSTM

OCI AI Foundations · Lesson 5 of 16 · 34:15

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Oracle Cloud Infrastructure AI Foundations Associate exam (1Z0-1122-26). In this lesson: how a convolutional neural network sees an image (filters, ReLU, pooling, fully connected layers, softmax, and dropout), its uses and limits, recurrent neural networks and their shapes (one to many, many to one, many to many), and LSTMs with their three gates. Includes three original practice questions, with Willowmere Motors, a fictional network of car dealerships and repair shops, as the example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Photos and notes

Willowmere wants two models: one that finds the damaged part in a photo, and one that reads the notes that mechanics type into each repair order, to spot recurring problems. Photos are grids of pixels, and notes are sequences of words, so each needs a different kind of network. This lesson covers both: convolutional networks for images, and recurrent networks and LSTMs for sequences.

How a CNN sees

A convolutional neural network, or CNN, is built for data on a grid, like images and video frames. Instead of treating every pixel on its own, it slides small filters, also called kernels, across the image, and each filter detects a local pattern, like an edge, a corner, or a texture. Early layers find simple patterns, and deeper layers combine them into shapes and parts, like a wheel or a headlight. So the network learns which features matter, straight from the pixels.

The layers of a CNN

A CNN has three groups of layers. The input layer takes the image. Feature extraction layers repeat convolution, then an activation function like ReLU, then pooling, which shrinks each feature map and keeps the strongest signals. At the end, classification layers are fully connected: they combine all the features, and a softmax function turns the result into a probability for each class, while dropout switches off random neurons during training, to prevent overfitting. CNNs classify images, detect objects with bounding boxes, split images into regions, pixel by pixel, recognize faces, and analyze medical scans, but they need lots of data and computation, they can overfit, they're hard to explain, and small changes in an image can fool them.

Recurrent neural networks

Sequences are different: in text, speech, music, or a time series, the order matters, and each item depends on what came before. A recurrent neural network, or RNN, processes a sequence one step at a time, with a feedback loop: its hidden state carries a memory of the previous steps into the next one. RNNs come in several shapes: one to many, like generating music from one note, many to one, like reading a whole review to give one sentiment, and many to many, like translating a sentence, or labeling each word. Their weakness is long sequences: as the error flows back through many steps, the gradient becomes tiny, the vanishing gradient problem, and the network forgets what came early.

LSTM

Long short-term memory networks, or LSTMs, fix this forgetting problem. An LSTM cell keeps a cell state, a long-term memory that runs through the whole sequence, next to its hidden state. Three gates control it: the input gate decides what new information to store, the forget gate decides what to drop, and the output gate decides what to pass on. So an LSTM can remember a detail from the start of a long repair note, like the car model, when it reads the end. For very long texts, transformers, which you meet in lesson seven, now do even better.

Recap

Let's recap. CNNs slide filters across grid data, like images, to detect local patterns, from edges to whole parts. Convolution, ReLU, and pooling find features, then fully connected layers and softmax classify, and dropout fights overfitting. RNNs process sequences step by step, with a hidden state as memory, in one to many, many to one, or many to many shapes. On long sequences, their gradient vanishes, and they forget. LSTMs add a cell state and three gates, input, forget, and output, to remember longer.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. In Willowmere’s damage network, which part turns the final scores into a probability for each type of damage?

    • The pooling layer
    • The softmax function
    • The convolution layer
    • Dropout
    Show the answer

    The softmax function

    At the end of the classification layers, softmax turns the scores into a probability for each class. “The pooling layer” would shrink the feature maps, early in the network. “The convolution layer” would detect local patterns with filters, not give probabilities. And “Dropout” only switches off random neurons during training, to prevent overfitting.

  2. Willowmere wants a model that reads a customer’s whole review, word by word, and gives one sentiment at the end. Which RNN shape is this?

    • One to one
    • One to many
    • Many to many
    • Many to one
    Show the answer

    Many to one

    A whole sequence goes in, and one output comes out, so it's many to one. “One to one” has one input and one output, with no sequence at all. “One to many” would start from one input, and produce a whole sequence, like music from one note. And “Many to many” would produce a sequence as well, like a translation, or a label for each word.

  3. An LSTM reads a long repair note. Which part decides what information to drop from its cell state?

    • The forget gate
    • The input gate
    • The output gate
    • The pooling layer
    Show the answer

    The forget gate

    The forget gate decides what to drop from the cell state. “The input gate” decides what new information to store, not what to drop. “The output gate” decides what to pass on to the next step and to the output. And “The pooling layer” belongs to convolutional networks, which shrink feature maps, and have no cell state.