How can i change the preset model to accept custom shape?

Recently, i want to use the torchvision.models.video.r2plus1d_18 , but i found the needed input shape is
(3 x T x H x W), but my input is (2 x T x H x W), so there is a solution to modify the preset model to accept this kind of shape? i am confused now…thx!!!

Hi @Steve_Hu,

You can first try to zero pad the input:

# Given input = (B, 2, T, H, W)
input = torch.cat((input, torch.zeros(B, 1, T, H, W)), axis=1)

You can also modify the first layer and fine tune it with your 2 channels input. To modify it:

net = torchvision.models.video.r2plus1d_18()
r2.stem[0] = Conv3d(2, 45, kernel_size=(1, 7, 7), stride=(1, 2, 2), padding=(0, 3, 3), bias=False)
1 Like

thx very very much:heart:! i will try the second way:grin: