f2754e0656d8cebe1f785f6af100e4ade241a7f8,thinc/model.py,Model,set_grad,#Model#Any#Any#,285
Before Change
def set_grad(self, name: str, value: Array) -> None:
Set a gradient value for the model.
grad_name = f"d_{name}"
key = (self.id, grad_name)
if key not in self._mem:
self.inc_grad(name, value)
else:
data = self._mem[key]
try:
copy_array(dst=data, src=value)
except ValueError as e: // pragma: no cover
err = f"Cannot set grad "{grad_name}" for model "{self.name}": {e}"
raise ValueError(err)
def has_attr(self, name: str) -> bool:
Check whether the model has the given attribute.
return name in self._attrs
After Change
def set_grad(self, name: str, value: Array) -> None:
Set a gradient value for the model.
self._params.set_grad(self.id, name, value)
def inc_grad(self, name: str, value: Array) -> None:
Check whether the model has a gradient of the given name.
self._params.inc_grad(self.id, name, value)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances Project Name: explosion/thinc
Commit Name: f2754e0656d8cebe1f785f6af100e4ade241a7f8
Time: 2020-01-14
Author: honnibal+gh@gmail.com
File Name: thinc/model.py
Class Name: Model
Method Name: set_grad
Project Name: explosion/thinc
Commit Name: f2754e0656d8cebe1f785f6af100e4ade241a7f8
Time: 2020-01-14
Author: honnibal+gh@gmail.com
File Name: thinc/model.py
Class Name: Model
Method Name: copy
Project Name: explosion/thinc
Commit Name: f2754e0656d8cebe1f785f6af100e4ade241a7f8
Time: 2020-01-14
Author: honnibal+gh@gmail.com
File Name: thinc/model.py
Class Name: Model
Method Name: finish_update