A method for training a machine learning model is provided. In this method, samples are drawn from a first training set according to multiple weights for training the machine learning model in a first epoch. The first training set includes multiple levels corresponding to the multiple weights. After the first epoch, the machine learning model is evaluated using a validation set for multiple first performances at the multiple levels. Additionally, the weight that corresponds to each level is updated based on the first performances, and samples are redrawn from the first training set according to the updated weights for training the machine learning model in a second epoch that follows the first epoch. Moreover, an electronic device and a non-transitory computer-readable medium for utilizing the above method are also provided. |