a4f90c8e8420db451da188fcb50d7b801a5c6ff1,parlai/agents/fairseq/fairseq.py,FairseqAgent,report,#FairseqAgent#,546

Before Change



        // These are the metrics we"ll pass up the way, and their new names
        train_metrics = {"train_loss", "ups", "wps", "gnorm", "clip"}
        valid_metrics = {"valid_loss"}

        metrics = train_metrics if self.is_training else valid_metrics

        m = {k: self.trainer.meters[k].avg for k in metrics}

        // additionally output perplexity. note that fairseq models use base 2
        // in cross_entropy:
        // github.com/pytorch/fairseq/blob/master/fairseq/criterions/cross_entropy.py//L55
        if "train_loss" in m:
            m["train_ppl"] = np.exp2(m["train_loss"])
        if "valid_loss" in m:
            m["ppl"] = np.exp2(m["valid_loss"])

        for k, v in m.items():
            // clean up: rounds to sigfigs and converts tensors to floats
            m[k] = round_sigfigs(v, 4)

After Change


                output[k] = self.trainer.meters[k].avg

        // for display purposes
        output = {k: round_sigfigs(v, 4) for k, v in output.items()}
        return output

    def reset_metrics(self):
        Reset metrics calculated by the model back to zero.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: facebookresearch/ParlAI
Commit Name: a4f90c8e8420db451da188fcb50d7b801a5c6ff1
Time: 2018-09-07
Author: roller@fb.com
File Name: parlai/agents/fairseq/fairseq.py
Class Name: FairseqAgent
Method Name: report


Project Name: pandas-dev/pandas
Commit Name: 4a6c3c56f54bf1f85f35aaae76dc76e7cf567b8f
Time: 2020-10-10
Author: 45562402+rhshadrach@users.noreply.github.com
File Name: pandas/core/aggregation.py
Class Name:
Method Name: aggregate


Project Name: oddt/oddt
Commit Name: 86698c801848975de9a21fb17093e045b6271ea3
Time: 2018-05-17
Author: maciek@wojcikowski.pl
File Name: rdkit_fixer.py
Class Name:
Method Name: PreparePDBMol