@Dimitrisl: as @unnatjain said, if you pass a (5, 9, 12) tensor through a linear(12, 1) layer, it will automatically apply the linear transformation only onto the last dimension, giving you a (5, 9, 1) tensor. No iteration required.