Solved by ptrblck in post #2 
              
              
                Yes, you are skipping dim1, as you don’t want to calculate the mean in this dimension. 
The code can also be written as X_train.mean([0, 2, 3], keepdim=True).