# Gate logic without memorizing a story

Subject: Deep Learning

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/#tee/read/9/tee-c9-s19

Canonical: https://deep-learning-study-room.vercel.app/read/dl/tee/section/tee-c9-s19/

In an LSTM, let the previous cell be 2, forget gate 0.5, input gate 0.25, candidate −0.4 and output gate 1. Calculate the retained part, admitted part, new cell and hidden output.

![The input gate multiplies candidate content. The output gate is applied after updating and activating the cell.](https://deep-learning-study-room.vercel.app/assets/figures/v_gate_order.svg)

Diagram: The input gate multiplies candidate content. The output gate is applied after updating and activating the cell.. Labels: Keep the order of gate calculations straight | Keep the order of gate calculations straight | The cell equation specifies what each gate multiplies. | Forget path | Old cell × | forget gate | Input path | Candidate × | input gate | Cell update | Add those two | parts | Hidden output | tanh(new cell) | × output gate | The input gate multiplies the candidate, not simply the raw input x.

The input gate multiplies candidate content. The output gate is applied after updating and activating the cell. Tap the diagram to enlarge.

**Step 1 retained content:** 0.5 × 2 = 1.

**Step 2 admitted content:** 0.25 × (−0.4) = −0.1. A candidate can be negative even though the gate itself is between zero and one.

**Step 3 cell:** 1 + (−0.1) = 0.9.

**Step 4 hidden:** output gate × tanh(cell) = 1 × tanh(0.9) ≈ 0.716298. The hidden output is not simply 0.9. Explain this distinction once before attempting another LSTM numerical.
