Hi Team,

# Below is my query

image = torch.randn(1,256,16,16)

#Target color blue
Target_color_blue = torch.zeros(1, 1, 3, dtype=torch.float)
Target_color_blue[:,:,2] = 255

#Target color red
Target_color_red = torch.zeros(1, 1, 3, dtype=torch.float)
Target_color_red[:,:,0] = 255

#Target color green
Target_color_green = torch.zeros(1, 1, 3, dtype=torch.float)
Target_color_green[:,:,1] = 128

Target_color_list = [Target_color_blue,Target_color_red,Target_color_green]
#Stacking both red and blue tensors
Target_colors = torch.stack(Target_color_list)

Want to multiply

# Target color shape is torch.Size([3, 1, 1, 3]) while image shape is (1,256,16,16)

So final shape should be of length 3

@KURUVILLA_ABRAHAM your image is of size (1,256,16,16)

What do the individual dimensions denote

• Which one denotes channel : If the channel is 256 or 16 how do we select the channel for multiplication with the target color

• Is the size of the image 16 height * 16 width?

• Just curious to know, what are you trying to achieve through this

Can you provide a sample output.

Hello anant ,

(1,256,16,16) - represent (batch * channel* height * width)
Target colors in this case are 3 - I am using below code to produce it

#Target color blue
Target_color_blue = torch.zeros(1, 1, 3, dtype=torch.float)
Target_color_blue[:,:,2] = 255

#Target color red
Target_color_red = torch.zeros(1, 1, 3, dtype=torch.float)
Target_color_red[:,:,0] = 255

#Target color green
Target_color_green = torch.zeros(1, 1, 3, dtype=torch.float)
Target_color_green[:,:,1] = 128

Target_color_list = [Target_color_blue,Target_color_red,Target_color_green]
#Stacking both red and blue tensors
Target_colors = torch.stack(Target_color_list)

now my output should be -

# all colors mutiplied with image1

image1Target_color1
image1
Target_color2
image1*Target_color3

# all colors mutiplied with image2

image2Target_color1
image2
Target_color2
image2*Target_color3

@KURUVILLA_ABRAHAM in that case there is mismatch between the number of channels in the Target_colors and the channels in image

Taget_colors have 3 channels and image has 256 channels. How will we able to multiply?

Ok in that case if I increase the color dimension to 256 will it impact my color

Absolutely. 3 Channels refer to RGB
If you change to 256 you will have to come up with your own understanding of what each channel means, as it is a mathematical representation