skip to content
promptdojo
_
[ save your spot ]
[ follow on x ]
Broadcasting and vectorization — step 2 of 7
ch 42 · pytorch tensors and autograd
2/7
promptdojo
_
›
phase 06 · ml systems
›
ch 42 · pytorch tensors and autograd
lesson 2 of 4 · broadcasting and vectorization
step 2 of 7 in this lesson
In torch, what happens when you add a (3,)-shaped tensor to a (3, 1)-shaped tensor?
1
Shape error — 3 and 1 don't match
2
(3,) — the column collapses onto the vector
3
It silently broadcasts to (3, 3) — a matrix you never asked for
4
(3, 1) — the left operand's shape wins
check
Show hint 1
ch 42 · pytorch tensors and autograd
2/7
promptdojo
_
›
phase 06 · ml systems
›
ch 42 · pytorch tensors and autograd
lesson 2 of 4 · broadcasting and vectorization
step 2 of 7 in this lesson
In torch, what happens when you add a (3,)-shaped tensor to a (3, 1)-shaped tensor?
1
Shape error — 3 and 1 don't match
2
(3,) — the column collapses onto the vector
3
It silently broadcasts to (3, 3) — a matrix you never asked for
4
(3, 1) — the left operand's shape wins
check
Show hint 1
park a thought