Movement
Movement ops change the shape of a tensor or the order of its elements, never their values.
Movement¤
reshape
¤
reshape(*shape)
Same data in a new shape; one dim may be -1.
Source code in stackgrad/tensor.py
269 270 271 | |
permute
¤
permute(*order)
Source code in stackgrad/tensor.py
273 274 | |
transpose
¤
transpose(dim0=-2, dim1=-1)
Swap two axes, the last two by default.
Source code in stackgrad/tensor.py
276 277 278 279 280 | |
expand
¤
expand(*shape)
Broadcast to shape, adding leading dims if needed.
Source code in stackgrad/tensor.py
282 283 284 285 286 | |
squeeze
¤
squeeze(axis=None)
Source code in stackgrad/tensor.py
288 289 290 | |
unsqueeze
¤
unsqueeze(axis)
Source code in stackgrad/tensor.py
292 293 294 | |
im2col
¤
im2col(kh, kw, stride=1, padding=0)
(N, C, H, W) -> (NOHOW, Ckhkw) patch rows, the input to a conv-as-matmul.
Source code in stackgrad/tensor.py
305 306 307 | |
Combining¤
cat
¤
cat(tensors, axis=0)
Concatenate tensors along an existing axis.
Source code in stackgrad/tensor.py
416 417 418 | |
stack
¤
stack(tensors, axis=0)
Stack tensors along a new axis.
Source code in stackgrad/tensor.py
421 422 423 | |