简体   繁体   English

减少 PyTorch 中 5D 张量的通道数

[英]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.为了减少 4D 张量中特征图的数量,可以使用 Conv2d,同时保持该张量的高度和宽度与以前相同。 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:更清楚地说,例如对于以下 4D 张量 [batch_size、feature_maps、height、weight],我使用以下方法来减少特征图的数量,但高度和大小将与以前相同:

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] (eg [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 (eg [16, 1024, 16, 56, 56]).但是我有以下 5D 张量 [batch_size, feature_maps, num_frames, height, width](例如 [16, 1024, 16, 56, 56]),我想在保持高度的同时将特征图的数量从 1024 减少到 512和宽度大小与以前相同(例如 [16, 1024, 16, 56, 56])。 How can I reduce the number of feature maps?如何减少特征图的数量?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM