Deep Learning Academy · レッスン

基本的なRNNセル

ステップをまたいで隠れ状態を受け渡します

レッスン 2/413 ステップ

「基本的なRNNセル」はCoddyKit上の無料Deep Learning Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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. ✅

無料で開始

AI チューターと学ぶ Python — 無料

ブラウザでリアルコードを書いて実行し、24/7 の AI チューターから瞬時にサポートを受け、ウェブまたはアプリで続きから学習できます。

コース
30
レッスン
120

よくある質問

「基本的なRNNセル」レッスンは無料ですか?

はい。「基本的なRNNセル」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Deep Learning Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Deep Learning Academyコースには全4レッスンが含まれています。

「基本的なRNNセル」で何を学びますか?

ステップをまたいで隠れ状態を受け渡します ブラウザで直接実行するハンズオンコードでDeep Learning Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Deep Learning Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのDeep Learning Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「基本的なRNNセル」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このDeep Learning Academyレッスンでコードを書いて実行できますか?

はい。すべてのDeep Learning Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 系列にメモリが必要な理由
  2. 基本的なRNNセル
  3. LSTMとGRUのゲート
  4. 系列をパックしてパディングを扱う
← Deep Learning Academyに戻る