La celda RNN básica
Mantenga un estado oculto entre pasos
La celda RNN básica es una lección gratuita de Deep Learning Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Deep Learning Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Deep Learning Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
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_yUse 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. ✅
Preguntas frecuentes
¿La lección «La celda RNN básica» es gratis?
Sí — el texto completo de «La celda RNN básica» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Deep Learning Academy, actualiza a CoddyKit PRO. El curso de Deep Learning Academy incluye 4 lecciones en total.
¿Qué aprenderé en «La celda RNN básica»?
Mantenga un estado oculto entre pasos Practicas Deep Learning Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Deep Learning Academy?
No se requiere experiencia previa. Deep Learning Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «La celda RNN básica»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Deep Learning Academy?
Sí. Cada lección de Deep Learning Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Por qué las secuencias necesitan memoria
- La celda RNN básica
- Puertas LSTM y GRU
- Empaquete secuencias y gestione el padding