f2754e0656d8cebe1f785f6af100e4ade241a7f8,thinc/model.py,Model,finish_update,#Model#Any#,371
Before Change
seen: Set[int] = set()
for node in self.walk():
if node.id not in seen:
// Kind of ugly to use the _mem.weights -- would make more sense
// to call node.finish_update. Maybe we could pass in a set
// of visited?
optimizer(node._mem.weights, node._mem.gradient, key=node.id)
seen.add(node.id)
for shim in node.shims:
shim.finish_update(optimizer)
@contextlib.contextmanager
def use_params(self, params: Dict[int, Array]):
Context manager to temporarily set the model"s parameters to
specified values. The params are a dictionary keyed by model IDs, whose
After Change
with each parameter and gradient of the model.
for node in self.walk():
for name in node.param_names:
if node.has_grad(name):
param = node.get_param(name)
grad = node.get_grad(name)
param, grad = optimizer(param, grad, key=(node.id, name))
node.set_param(name, param)
node.set_grad(name, grad)
for shim in node.shims:
shim.finish_update(optimizer)
@contextlib.contextmanager
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
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: finish_update
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: from_bytes
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: use_params