ec54a0b75d93cab5ad407920f2bbfd2f33251cc9,pytext/trainers/trainer.py,Trainer,train,#Trainer#Any#Any#Any#Any#Any#Any#Any#Any#,62

Before Change


            sys.stdout.flush()

        if rank == 0:
            model.load_state_dict(torch.load(best_model_path))
        return model, best_metric

    def _run_epoch(
        self,

After Change


                    if cuda_utils.CUDA_ENABLED:
                        for key, state in model_state.items():
                            model_state[key] = state.cpu()
                    best_model_state = model_state

            if self.config.early_stop_after > 0 and (
                epoch - last_best_epoch == self.config.early_stop_after
            ):
                print(
                    f"Rank {rank} worker: Eval metric hasn"t changed for "
                    + f"{self.config.early_stop_after} epochs. Stopping now."
                )
                break
            sys.stdout.flush()

        if rank == 0:
            if cuda_utils.CUDA_ENABLED:
                for key, state in best_model_state.items():
                    best_model_state[key] = state.cuda()
            model.load_state_dict(best_model_state)
        return model, best_metric

    def _run_epoch(
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: facebookresearch/pytext
Commit Name: ec54a0b75d93cab5ad407920f2bbfd2f33251cc9
Time: 2019-01-18
Author: zsc@fb.com
File Name: pytext/trainers/trainer.py
Class Name: Trainer
Method Name: train


Project Name: Scitator/catalyst
Commit Name: 60dfcf812eca79017dced46e1189245c050a3fd6
Time: 2018-12-10
Author: scitator@gmail.com
File Name: utils/factory.py
Class Name: UtilsFactory
Method Name: unpack_checkpoint


Project Name: PacktPublishing/Deep-Reinforcement-Learning-Hands-On
Commit Name: f1fe81e01edd0fa3163bd1a5a8db09ead0cd6a22
Time: 2018-02-20
Author: max.lapan@gmail.com
File Name: ch16/02_breakout_es.py
Class Name:
Method Name: eval_with_noise