mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
pre-commit: Add ruff to replace bandit, flake8, isort, and pyupgrade (#1210)
* pre-commit: Add ruff to replace bandit, flake8, isort, and pyupgrade * Upgrade ruff * Update .pre-commit-config.yaml * Update .pre-commit-config.yaml * Update .pre-commit-config.yaml
This commit is contained in:
@@ -99,7 +99,9 @@ def micrograd_demo(*args, **kwargs):
|
||||
scores = list(map(model, inputs))
|
||||
|
||||
# svm "max-margin" loss
|
||||
losses = [(1 + -yi * scorei).relu() for yi, scorei in zip(yb, scores)]
|
||||
losses = [
|
||||
(1 + -yi * scorei).relu() for yi, scorei in zip(yb, scores, strict=True)
|
||||
]
|
||||
data_loss = sum(losses) * (1.0 / len(losses))
|
||||
# L2 regularization
|
||||
alpha = 1e-4
|
||||
@@ -109,7 +111,7 @@ def micrograd_demo(*args, **kwargs):
|
||||
# also get accuracy
|
||||
accuracy = [
|
||||
((yi).__gt__(0)) == ((scorei.data).__gt__(0))
|
||||
for yi, scorei in zip(yb, scores)
|
||||
for yi, scorei in zip(yb, scores, strict=True)
|
||||
]
|
||||
return total_loss, sum(accuracy) / len(accuracy)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user