mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
Auto-format code with black (#10209)
* Auto-format code with black * add black requirement to dev dependencies and pin to 22.x * ignore black dependency for comparison with setup.cfg Co-authored-by: explosion-bot <explosion-bot@users.noreply.github.com> Co-authored-by: svlandeg <svlandeg@github.com>
This commit is contained in:
parent
0668a449ba
commit
91ccacea12
|
@ -35,3 +35,4 @@ mypy==0.910
|
||||||
types-dataclasses>=0.1.3; python_version < "3.7"
|
types-dataclasses>=0.1.3; python_version < "3.7"
|
||||||
types-mock>=0.1.1
|
types-mock>=0.1.1
|
||||||
types-requests
|
types-requests
|
||||||
|
black>=22.0,<23.0
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Language:
|
||||||
self,
|
self,
|
||||||
vocab: Union[Vocab, bool] = True,
|
vocab: Union[Vocab, bool] = True,
|
||||||
*,
|
*,
|
||||||
max_length: int = 10 ** 6,
|
max_length: int = 10**6,
|
||||||
meta: Dict[str, Any] = {},
|
meta: Dict[str, Any] = {},
|
||||||
create_tokenizer: Optional[Callable[["Language"], Callable[[str], Doc]]] = None,
|
create_tokenizer: Optional[Callable[["Language"], Callable[[str], Doc]]] = None,
|
||||||
batch_size: int = 1000,
|
batch_size: int = 1000,
|
||||||
|
|
|
@ -85,7 +85,7 @@ def get_characters_loss(ops, docs, prediction, nr_char):
|
||||||
target = ops.asarray(to_categorical(target_ids, n_classes=256), dtype="f")
|
target = ops.asarray(to_categorical(target_ids, n_classes=256), dtype="f")
|
||||||
target = target.reshape((-1, 256 * nr_char))
|
target = target.reshape((-1, 256 * nr_char))
|
||||||
diff = prediction - target
|
diff = prediction - target
|
||||||
loss = (diff ** 2).sum()
|
loss = (diff**2).sum()
|
||||||
d_target = diff / float(prediction.shape[0])
|
d_target = diff / float(prediction.shape[0])
|
||||||
return loss, d_target
|
return loss, d_target
|
||||||
|
|
||||||
|
|
|
@ -377,7 +377,7 @@ class SpanCategorizer(TrainablePipe):
|
||||||
# If the prediction is 0.9 and it's false, the gradient will be
|
# If the prediction is 0.9 and it's false, the gradient will be
|
||||||
# 0.9 (0.9 - 0.0)
|
# 0.9 (0.9 - 0.0)
|
||||||
d_scores = scores - target
|
d_scores = scores - target
|
||||||
loss = float((d_scores ** 2).sum())
|
loss = float((d_scores**2).sum())
|
||||||
return loss, d_scores
|
return loss, d_scores
|
||||||
|
|
||||||
def initialize(
|
def initialize(
|
||||||
|
|
|
@ -281,7 +281,7 @@ class TextCategorizer(TrainablePipe):
|
||||||
bp_scores(gradient)
|
bp_scores(gradient)
|
||||||
if sgd is not None:
|
if sgd is not None:
|
||||||
self.finish_update(sgd)
|
self.finish_update(sgd)
|
||||||
losses[self.name] += (gradient ** 2).sum()
|
losses[self.name] += (gradient**2).sum()
|
||||||
return losses
|
return losses
|
||||||
|
|
||||||
def _examples_to_truth(
|
def _examples_to_truth(
|
||||||
|
@ -315,7 +315,7 @@ class TextCategorizer(TrainablePipe):
|
||||||
not_missing = self.model.ops.asarray(not_missing) # type: ignore
|
not_missing = self.model.ops.asarray(not_missing) # type: ignore
|
||||||
d_scores = (scores - truths) / scores.shape[0]
|
d_scores = (scores - truths) / scores.shape[0]
|
||||||
d_scores *= not_missing
|
d_scores *= not_missing
|
||||||
mean_square_error = (d_scores ** 2).sum(axis=1).mean()
|
mean_square_error = (d_scores**2).sum(axis=1).mean()
|
||||||
return float(mean_square_error), d_scores
|
return float(mean_square_error), d_scores
|
||||||
|
|
||||||
def add_label(self, label: str) -> int:
|
def add_label(self, label: str) -> int:
|
||||||
|
|
|
@ -12,6 +12,7 @@ def test_build_dependencies():
|
||||||
"flake8",
|
"flake8",
|
||||||
"hypothesis",
|
"hypothesis",
|
||||||
"pre-commit",
|
"pre-commit",
|
||||||
|
"black",
|
||||||
"mypy",
|
"mypy",
|
||||||
"types-dataclasses",
|
"types-dataclasses",
|
||||||
"types-mock",
|
"types-mock",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user