# How can I reduce the dimension of 3d tensor to 2d using convolutional filters?

**URL:** <https://discuss.pytorch.org/t/how-can-i-reduce-the-dimension-of-3d-tensor-to-2d-using-convolutional-filters/166142>\
**Category:** Uncategorized\
**Created:** [November 16, 2022, 7:48pm UTC](https://discuss.pytorch.org/t/how-can-i-reduce-the-dimension-of-3d-tensor-to-2d-using-convolutional-filters/166142 "2022-11-16T19:48:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![juanitapuentes](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/juanitapuentes/32/54903_2.png) [@juanitapuentes](https://discuss.pytorch.org/u/juanitapuentes)\
**Post date:** [November 16, 2022, 7:48pm UTC](https://discuss.pytorch.org/t/how-can-i-reduce-the-dimension-of-3d-tensor-to-2d-using-convolutional-filters/166142/1 "2022-11-16T19:48:54Z")

</div>

I have one question about the dimension of a tensor

1. How do I convert my model output torch.Size([2560, 128, 128]) to torch.Size([2560,128]) using convolutions?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [November 16, 2022, 8:27pm UTC](https://discuss.pytorch.org/t/how-can-i-reduce-the-dimension-of-3d-tensor-to-2d-using-convolutional-filters/166142/2 "2022-11-16T20:27:46Z")

</div>

You could use an `nn.Conv1d` layer with a kernel size of `128` and squeeze the output tensor in `dim2` afterwards:

```python
conv = nn.Conv1d(in_channels=128, out_channels=128, kernel_size=128)
x = torch.randn(2560, 128, 128)

out = conv(x)
out = out.squeeze(2)
print(out.shape)
# torch.Size([2560, 128])

```
