LinearLayer + BatchNorm1d with a 3D input

Hello,

I would like to apply a BatchNorm1d just after a LinearLayer. My input is a 3D multivariate time series of shape [batch_size, n_variables, timesteps]. The LinearLayer performs the linear transformation on the third dimension so that the new shape is [batch_size, n_variables, LinearLayer_out_features]. My problem occurs with the BatchNorm1d, I would like to apply it on the third dimension but, for a 3D input, BatchNorm1d operation is done over the second dimension (even for a 3D tensor). Do you have any suggestion on how to do that? Something like axis permuation?

Thank you in advance.

Filo

Perhaps input = input.transpose(1, 2) or input = input.permute(0, 2, 1)?

1 Like