In my previous code snippet each feature tensor had a feature dimension of 4.
I’ve collected all feature tensors belonging to the same class in a dict and appended them to a list.
Once this was done, I’ve calculated the mean of all tensors in the “batch dimension”, which creates a mean tensor of the shape [features].
I.e. if you have 10 tensors, where each tensor has a feature dimension of 4, your tensor would have a shape of [10, 4]. Calculating tensor.mean(dim=0) creates a mean tensor in the shape [4].