73b2221b5eb4fd21802e6bf41e21d5df8ef9bf2c,src/sdk/pynni/nni/nas/pytorch/darts/trainer.py,DartsTrainer,_compute_hessian,#DartsTrainer#Any#Any#Any#Any#,119

Before Change


                    p += eps * d

            self.mutator.reset()
            loss = self.loss(self.model(trn_X), trn_y)
            if e > 0:
                dalpha_pos = torch.autograd.grad(loss, self.mutator.parameters())  // dalpha { L_trn(w+) }
            elif e < 0:

After Change


        if norm < 1E-8:
            logger.warning("In computing hessian, norm is smaller than 1E-8, cause eps to be %.6f.", norm.item())

        dalphas = []
        for e in [eps, -2. * eps]:
            // w+ = w + eps*dw`, w- = w - eps*dw`
            with torch.no_grad():
                for p, d in zip(self.model.parameters(), dw):
                    p += e * d

            _, loss = self._logits_and_loss(trn_X, trn_y)
            dalphas.append(torch.autograd.grad(loss, self.mutator.parameters()))

        dalpha_pos, dalpha_neg = dalphas  // dalpha { L_trn(w+) }, // dalpha { L_trn(w-) }
        hessian = [(p - n) / 2. * eps for p, n in zip(dalpha_pos, dalpha_neg)]
        return hessian
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: Microsoft/nni
Commit Name: 73b2221b5eb4fd21802e6bf41e21d5df8ef9bf2c
Time: 2019-11-22
Author: v-yugzh@microsoft.com
File Name: src/sdk/pynni/nni/nas/pytorch/darts/trainer.py
Class Name: DartsTrainer
Method Name: _compute_hessian


Project Name: deepmipt/DeepPavlov
Commit Name: 1a6d4020c53e2b39e224616481528fad901cbd4e
Time: 2018-10-15
Author: yoptar@gmail.com
File Name: deeppavlov/core/commands/infer.py
Class Name:
Method Name: predict_on_stream


Project Name: biolab/orange3
Commit Name: a0d5162fb500d43f4be26fd402271fc888397464
Time: 2015-06-24
Author: anze.staric@gmail.com
File Name: Orange/tests/test_classification.py
Class Name: LearnerAccessibility
Method Name: test_all_models_work_after_unpickling