Basic Pytorch tensor multiplication and addition
I just realize I lack some very basic pytorch tensor math. How do I do the following with a pytorch tensor?

lab_rs = (lab_rs * [100, 255, 255] - [0, 128, 128])

This works well in numpy. It's an image with shape (3, 512, 1024) and I want to multiply and subtract values from each color channel individually

The error I get trying the same with a tensor is:

TypeError: only integer tensors of a single element can be converted to an index


You need to make sure all your operands can be broadcast to the same dimensions:

lab_rs = lab_rs * torch.tensor([[[100]], [[255]], [[255.]]]) - torch.tensor([[[0]], [[128]], [[128.]]])

