Portas que controlam a memória
Como LSTMs decidem o que manter.
Portas que controlam a memória é uma aula grátis de NLP Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de NLP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de NLP Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
Plain RNNs Forget
A simple RNN struggles to remember things from far back. The LSTM was built to fix that by carefully managing what it keeps and forgets. 🧠
The Cell State
An LSTM carries a special cell state, a memory line that runs straight through every step so important signals survive long sequences.
Gates Are the Trick
The magic is in the gates: tiny learned switches that decide what to add, keep, or drop from memory at each time step.
How a Gate Works
Each gate uses a sigmoid to output values from 0 to 1, acting like a dimmer that lets some information through and blocks the rest.
gate = sigmoid(W @ x + U @ h + b) # values in [0, 1]The Forget Gate
The forget gate looks at the new input and decides how much of the old memory to erase. A 0 wipes it; a 1 keeps it fully.
The Input Gate
The input gate controls how much fresh information gets written into the cell state, so only useful new signals are stored.
The Candidate Values
A candidate vector proposes what new content could enter memory. The input gate then scales how much of it actually gets added.
candidate = tanh(W @ x + U @ h + b)Updating Memory
The new cell state blends old memory kept by the forget gate with fresh candidate values let in by the input gate.
c = forget * c_prev + input * candidateThe Output Gate
The output gate decides what part of the cell state becomes the visible hidden state passed to the next step and the layer above.
Why Gates Beat Forgetting
Because gates keep the cell state mostly additive, gradients flow back many steps without vanishing. That is how an LSTM remembers long context.
Three Gates, One Cell
So an LSTM has three gates guarding one memory line: forget, input, and output, each learned from data during training.
Quick Check
Test your grip on LSTM gates.
Recap
An LSTM protects a cell state with forget, input, and output gates. Those switches keep long-range memory alive where plain RNNs fail. ✅
Perguntas Frequentes
A aula “Portas que controlam a memória” é grátis?
Sim — o texto completo de “Portas que controlam a memória” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de NLP Academy, atualize para CoddyKit PRO. O curso de NLP Academy inclui 4 aulas no total.
O que vou aprender em “Portas que controlam a memória”?
Como LSTMs decidem o que manter. Você pratica NLP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar NLP Academy?
Nenhuma experiência prévia é necessária. NLP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.
Quanto tempo leva a aula “Portas que controlam a memória”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de NLP Academy?
Sim. Cada aula de NLP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Portas que controlam a memória
- GRU: uma alternativa mais enxuta
- Treinando um classificador LSTM
- Camadas bidirecionais e empilhadas