mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-09 16:10:33 +03:00
Remove unused methods
This commit is contained in:
parent
ba22111ff4
commit
2c7a32cf12
|
@ -152,30 +152,11 @@ class Pipe:
|
||||||
return sgd
|
return sgd
|
||||||
|
|
||||||
def set_output(self, nO):
|
def set_output(self, nO):
|
||||||
# TODO: document this across components?
|
|
||||||
if self.model.has_dim("nO") is not False:
|
if self.model.has_dim("nO") is not False:
|
||||||
self.model.set_dim("nO", nO)
|
self.model.set_dim("nO", nO)
|
||||||
if self.model.has_ref("output_layer"):
|
if self.model.has_ref("output_layer"):
|
||||||
self.model.get_ref("output_layer").set_dim("nO", nO)
|
self.model.get_ref("output_layer").set_dim("nO", nO)
|
||||||
|
|
||||||
def get_gradients(self):
|
|
||||||
"""Get non-zero gradients of the model's parameters, as a dictionary
|
|
||||||
keyed by the parameter ID. The values are (weights, gradients) tuples.
|
|
||||||
"""
|
|
||||||
# TODO: How is this used?
|
|
||||||
gradients = {}
|
|
||||||
queue = [self.model]
|
|
||||||
seen = set()
|
|
||||||
for node in queue:
|
|
||||||
if node.id in seen:
|
|
||||||
continue
|
|
||||||
seen.add(node.id)
|
|
||||||
if hasattr(node, "_mem") and node._mem.gradient.any():
|
|
||||||
gradients[node.id] = [node._mem.weights, node._mem.gradient]
|
|
||||||
if hasattr(node, "_layers"):
|
|
||||||
queue.extend(node._layers)
|
|
||||||
return gradients
|
|
||||||
|
|
||||||
def use_params(self, params):
|
def use_params(self, params):
|
||||||
"""Modify the pipe's model, to use the given parameter values. At the
|
"""Modify the pipe's model, to use the given parameter values. At the
|
||||||
end of the context, the original parameters are restored.
|
end of the context, the original parameters are restored.
|
||||||
|
|
|
@ -378,23 +378,6 @@ cdef class Parser:
|
||||||
del tutor
|
del tutor
|
||||||
return losses
|
return losses
|
||||||
|
|
||||||
def get_gradients(self):
|
|
||||||
"""Get non-zero gradients of the model's parameters, as a dictionary
|
|
||||||
keyed by the parameter ID. The values are (weights, gradients) tuples.
|
|
||||||
"""
|
|
||||||
gradients = {}
|
|
||||||
queue = [self.model]
|
|
||||||
seen = set()
|
|
||||||
for node in queue:
|
|
||||||
if node.id in seen:
|
|
||||||
continue
|
|
||||||
seen.add(node.id)
|
|
||||||
if hasattr(node, "_mem") and node._mem.gradient.any():
|
|
||||||
gradients[node.id] = [node._mem.weights, node._mem.gradient]
|
|
||||||
if hasattr(node, "_layers"):
|
|
||||||
queue.extend(node._layers)
|
|
||||||
return gradients
|
|
||||||
|
|
||||||
def get_batch_loss(self, states, golds, float[:, ::1] scores, losses):
|
def get_batch_loss(self, states, golds, float[:, ::1] scores, losses):
|
||||||
cdef StateClass state
|
cdef StateClass state
|
||||||
cdef Pool mem = Pool()
|
cdef Pool mem = Pool()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user