a = torch.randn(2, 2, 3)
a
tensor([[[ 0.3279, 0.7291, 0.6789], [ 0.4092, -0.0571, 0.5786]], [[ 0.0901, 0.1008, 1.4097], [-1.7903, -0.9582, 1.8200]]])
max_pool1d( input, kernel_size ), kernel_size: 滑动窗口大小
b = nn.functional.max_pool1d(a, a.size(2))
b.shape # torch.Size([2, 2, 1])
b
tensor([[[0.7291], [0.5786]], [[1.4097], [1.8200]]])