dtr43
dtr43

Reputation: 155

Reducing the number of channels in a 5D tensor in PyTorch

For reducing the number of feature maps in a 4D tensor, it is possible to use Conv2d while keeping the height and width of that tensor as the same as before. To be clearer, For example for the following 4D tensor [batch_size, feature_maps, height,weight] I use the following approach for reducing the number of feature maps but the height and size will be the same as before:

self.channel_reduction = nn.Conv2d(1024, 512, kernel_size=1, stride=1)

But I have the following 5D tensor [batch_size, feature_maps, num_frames, height, width] (e.g. [16, 1024, 16, 56, 56]) and I want to reduce the number of feature maps from 1024 to 512 while keeping the height and width size as the same as before (e.g. [16, 1024, 16, 56, 56]). How can I reduce the number of feature maps?

Upvotes: 0

Views: 362

Answers (1)

hkchengrex
hkchengrex

Reputation: 4826

self.channel_reduction = nn.Conv3d(1024, 512, kernel_size=1, stride=1)

Upvotes: 2

Related Questions