-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlstm.qmd
More file actions
54 lines (40 loc) · 1020 Bytes
/
Copy pathlstm.qmd
File metadata and controls
54 lines (40 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
title: "LSTM - Long Short-Term Memory"
format:
html:
code-fold: False
jupyter: python3
---
# 🧠 LSTM Theory
LSTMs are a type of Recurrent Neural Network capable of learning long-term dependencies. Useful in time series, NLP, and sequential tasks.
---
# ⚙️ Architecture Diagram
```{mermaid}
graph TD;
Input --> LSTMCell[LSTM Cell]
LSTMCell --> Output
LSTMCell --> Memory[Memory State]
```
---
# 🧪 Interactive Demo
```{python}
import ipywidgets as widgets
import torch
import torch.nn as nn
input_size = widgets.IntSlider(value=8, min=1, max=32, description='Input size')
display(input_size)
lstm = nn.LSTM(input_size=input_size.value, hidden_size=20, num_layers=2)
x = torch.randn(5, 3, input_size.value)
h0 = torch.randn(2, 3, 20)
c0 = torch.randn(2, 3, 20)
out, _ = lstm(x, (h0, c0))
out.shape
```
---
# 📝 Quick Quiz
::: {.quiz}
### What is the core strength of LSTMs?
1. Static image classification
2. Learning long-term dependencies
3. Simple math operations
:::