


scale_channels(imgs, scale)
scale_channels(more_imgs, scale)
scale_channels(videos, scale)



Manipulating dimensions
Use "align_to()" to permute large amounts of dimensions without
mentioning all of them as in required by "permute()".



tensor = torch.randn(2, 2, 2, 2, 2, 2)
named_tensor = tensor.refine_names('A', 'B', 'C', 'D', 'E', 'F')



# Move the F (dim 5) and E dimension (dim 4) to the front while keeping
   # the rest in the same order



tensor.permute(5, 4, 0, 1, 2, 3)
named_tensor.align_to('F', 'E', ...)



Use "flatten()" and "unflatten()" to flatten and unflatten dimensions,
respectively. These methods are more verbose than "view()" and
"reshape()", but have more semantic meaning to someone reading the
code.



imgs = torch.randn(32, 3, 128, 128)
named_imgs = imgs.refine_names('N', 'C', 'H', 'W')
flat_imgs = imgs.view(32, -1)
named_flat_imgs = named_imgs.flatten(['C', 'H', 'W'], 'features')


