This error is raised, if a batchnorm layer cannot calculate the running statistics from a scalar value.
Usually you would see it during training (model.train()) e.g. if the batch contains a single sample.
This might be the case, if the length of your dataset is not divisible by the batch size without a remainder, which would create a smaller batch in the last iteration.
If that’s the case, you could avoid it by dropping this potentially smaller batch using drop_last=True in your DataLoader.