CSE 163
Section AX
TA1 & TA2
Question of the Day: What is your favorite muffin?
How many chihuahuas are in this photo?
Housekeeping 🧼
Important Dates and Reminders
Game Plan
🏏
What we’ve Learned so far:
What we’ll cover today:
3
Convolution Example
4
9 | 8 | 7 |
6 | 5 | 4 |
3 | 2 | 1 |
Image
2 | 1 |
Kernel
| |
| |
| |
Output
Convolution Solution
5
9 | 8 | 7 |
6 | 5 | 4 |
3 | 2 | 1 |
Image
2 | 1 |
Kernel
2
1
26 | |
| |
| |
Output
Convolution Solution
6
9 | 8 | 7 |
6 | 5 | 4 |
3 | 2 | 1 |
Image
2 | 1 |
Kernel
2
26 | 23 |
| |
| |
Output
1
Convolution Solution
7
9 | 8 | 7 |
6 | 5 | 4 |
3 | 2 | 1 |
Image
2 | 1 |
Kernel
2
1
26 | 23 |
17 | |
| |
Output
Convolution Solution
8
9 | 8 | 7 |
6 | 5 | 4 |
3 | 2 | 1 |
Image
2 | 1 |
Kernel
2
1
Output
26 | 23 |
17 | 14 |
8 | 5 |
More Generic Formula for Result Size
10
Image
Kernel
width
height
k_height
k_width
(0, 0)
k[0]
k[1]
(1, 0)
…
(width - k_width, 0)
k[width - k_width]
Total of (width - k_width + 1) kernels because of zero based indexing!
So the shape of the result will be (height - k_height + 1, width - k_width + 1)
Broadcasting with
Problem 2
11
The Rules of Broadcasting
img.shape = (n, m, 3)
v.shape = (3,)
img.shape = (n, m, 3)
v.shape = (1, 1, 3)
img.shape = (n, m, 3)
v.shape = (n, m, 3)
Word Bank
np.zeros(shape, dtype=float, ...)
np.ones(shape, dtype=float, ...)
np.arange([start,], stop[,step,], ...)
np.sum(a, ...)
Practice problems! Open up accessibility-simulations.ipynb
Section code:
Solutions
Solutions pt2
Solutions pt3