0Pricing
Deep Learning Academy · Урок

Обычная ячейка RNN

Передавайте скрытое состояние между шагами

«Обычная ячейка RNN» — бесплатный урок Deep Learning Academy на CoddyKit. Это урок 2 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения Deep Learning Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс Deep Learning Academy содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

What a Cell Does

An RNN cell is the tiny engine that runs at each time step. You feed it one input and the old memory, and it returns the new memory.

Two Inputs Per Step

Every step the cell takes two things: the current input x and the previous hidden state. It mixes them into a fresh hidden state.

The Core Formula

The vanilla cell computes a weighted sum of input and memory, then squashes it. That single line is the heart of the RNN.

h_t = tanh(W_x @ x_t + W_h @ h_prev + b)

Why tanh?

The tanh activation keeps the hidden state bounded between -1 and 1, so memory values stay stable instead of blowing up over many steps.

Two Weight Matrices

One matrix W_x reads the new input; another W_h reads the old memory. The cell learns both to decide what to keep and what to add.

The Initial Hidden State

Before step one there is no memory, so the hidden state starts as a vector of zeros and gets filled in as the sequence flows through.

h0 = torch.zeros(hidden_size)

Unrolling Through Time

Picture the cell copied once per step, with memory passed along the chain. This view is called unrolling the network through time.

Outputs From Memory

Need a prediction at a step? Pass that step's hidden state through a small output layer to get logits or a value.

y_t = W_y @ h_t + b_y

Use It in PyTorch

PyTorch gives you nn.RNN so you don't hand-code the loop. You set input and hidden sizes, then feed a batched sequence.

rnn = nn.RNN(input_size=10, hidden_size=20)

Outputs and Final State

Calling the layer returns two things: the outputs at every step and the final hidden state, handy for classifying the whole sequence.

out, h_n = rnn(x)

The Catch

Vanilla RNNs work, but their memory fades fast over long sequences. That weakness sets the stage for gated cells like the LSTM.

Quick Check

What two things does a vanilla RNN cell take as input each step?

Recap

The vanilla cell blends input and old memory with tanh to make a new hidden state, repeated step by step across the sequence. ✅

Часто задаваемые вопросы

Урок «Обычная ячейка RNN» бесплатный?

Да — полный текст урока «Обычная ячейка RNN» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Deep Learning Academy, подпишись на CoddyKit PRO. Курс Deep Learning Academy содержит 4 уроков всего.

Чему я научусь в уроке «Обычная ячейка RNN»?

Передавайте скрытое состояние между шагами Ты практикуешь Deep Learning Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать Deep Learning Academy?

Предыдущий опыт не требуется. Deep Learning Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 2 из 4.

Сколько времени занимает урок «Обычная ячейка RNN»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке Deep Learning Academy?

Да. Каждый урок Deep Learning Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Почему последовательностям нужна память
  2. Обычная ячейка RNN
  3. Вентили LSTM и GRU
  4. Упакуйте последовательности и обработайте дополнение
← Назад к Deep Learning Academy