Fastest, best (fastest) way to modify data in in a pytorch loss function?
I want to experiment with creating a modified Loss function for 4 channel image data.
What is the best way to split torch.Size([64, 4, 128, 128])
to
torch.Size([64, 3, 128, 128])
torch.Size([64, 1, 128, 128])

You can either slice the second axis and extract two tensors:
&gt;&gt;&gt; a, b = x[:, :3], x[:, 3:]
&gt;&gt;&gt; a.shape, b.shape
(64, 3, 128, 128), (64, 1, 128, 128)

Alternatively you can apply torch.split on the first dimension:
&gt;&gt;&gt; a, b = x.split(3, dim=1)
&gt;&gt;&gt; a.shape, b.shape
(64, 3, 128, 128), (64, 1, 128, 128)

