l have a dataset following this format [batch, channel, width, height]= [10000,1,256,256]
to train resnet l need to have 3 channels.
My question is how to transform my data with 1 channel to 3 channels
You can use
.expand for this:
a = torch.randn(10, 1, 256, 256)
a = a.expand(-1, 3, -1, -1)
Note that this will repeat the channel dimension.
thank you. This is what l’m looking for
Well, you are probably better off changing the first conv block parameters if you are only going to train on 1 channel data.
you can also do:
nn.Conv2d(1, 3, 1)(input)