Convert nn.Linear to nn.Conv1d
The format I want to output my model to doesn't support nn.Linear, so I'd like to change it to do the exact same thing but with nn.Conv1d.
My input is of shape (N, A, B) and I'd like to have a linear layer that transforms that into an output of shape (N, A, C). Previously, I was doing this with the layer nn.Linear(B, C). I'm able to produce working code that has the correct dimensions by doing
t1 = t1.transpose(1,2)
conv = nn.Conv1d(
            in_channels=B,
            out_channels=C,
            kernel_size=1
        )
t2 = conv(t1)
t2 = t2.transpose(1,2)

Is this functionally equivalent to doing t2 = nn.Linear(B,C)(t1)?
If so, is there a better/less verbose way of doing it?

Yes this is essentially doing the same thing.
Instead of transposing you could just add a trailing dummy dimension by doing
t1 = t1.unsqueeze(-1)
...
t2 = t2.squeeze(-1)

This has the advantage that the data doesn't have to be reordered, but the effect is probably negligible.
