def train(self):
        for epoch in range(self.start_epoch, self.epochs + 1):
            print(f"============== {epoch} epoch ==============")
            print("[0 seconds] Begin training...")
            timer = ExecutionTime()

            self._set_model_to_train_mode()
            self._train_epoch(epoch)

            if self.save_checkpoint_interval != 0 and epoch % self.save_checkpoint_interval == 0:
                print(
                    f"[{timer.duration()} seconds] Training is over, Saving..."
                )
                self._save_checkpoint(epoch)

            if self.validation_interval != 0 and epoch % self.validation_interval == 0:
                print(
                    f"[{timer.duration()} seconds] Validation is in progress..."
                )
                self._set_model_to_eval_mode()
                score = self._validation_epoch(epoch)

                if self._is_best_score(score, find_max=self.find_max):
                    self._save_checkpoint(epoch, is_best=True)

            print(f"[{timer.duration()} seconds] End this epoch.")
    def train(self):
        for epoch in range(self.start_epoch, self.epochs + 1):
            print(f"============ Train epoch = {epoch} ============")
            print("[0 seconds] 开始训练...")
            timer = ExecutionTime()
            self.viz.set_epoch(epoch)

            self._train_epoch(epoch)

            if epoch % self.save_period == 0:
                self._save_checkpoint(epoch)

            if self.validation_period != 0 and epoch % self.validation_period == 0:
                # 测试一轮,并绘制波形文件
                print(f"[{timer.duration()} seconds] 训练结束,开始计算评价指标...")
                score = self._valid_epoch(epoch)

                if self._is_best_score(score):
                    self._save_checkpoint(epoch, is_best=True)

            print(f"[{timer.duration()} seconds] 完成当前 Epoch.")