Enhancing dynamic domain generalization with weight perturbation training