Loading views...

Numpy broadcasting

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2023 May 25 6:15
Editor
Edited
Edited
2026 Aug 9 23:6
Refs
Refs

In-place semantics

(2, 3) + (3,) # -> (2, 3) (3,) + (2, 1) # -> (2, 3)
With broadcasting, the shape of the in-place tensor does not change.
notion image
1차원은 broadcasting되는데 2차원부터 안되니까 1차원만 되는 이유
차원 없다면 뒤부터 둔다
notion image
So in the first case above, the 3 cannot be placed in the middle.
 
 

Backwards compatibility

How does pytorch broadcasting work?
torch.add(torch.ones(4,1), torch.randn(4)) produces a Tensor with size: torch.Size([4,4]). Can someone provide a logic behind this?
How does pytorch broadcasting work?
pytorch broadcasting
Many PyTorch operations support NumPy's broadcasting semantics. what is broadcasting? NumPy docs에 공식설명은 아래와 같다. broadcasting Reference https://pytorc
pytorch broadcasting
 
 

Recommendations