Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
amaiya committed Jan 27, 2024
1 parent d7d7fca commit 89343ce
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: 23.1.0
rev: 24.1.0
hooks:
- id: black
#language_version: python3.6
Expand Down
6 changes: 3 additions & 3 deletions ktrain/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

from packaging import version

os.environ[
"NUMEXPR_MAX_THREADS"
] = "8" # suppress warning from NumExpr on machines with many CPUs
os.environ["NUMEXPR_MAX_THREADS"] = (
"8" # suppress warning from NumExpr on machines with many CPUs
)

# TensorFlow
SUPPRESS_DEP_WARNINGS = strtobool(os.environ.get("SUPPRESS_DEP_WARNINGS", "1"))
Expand Down
16 changes: 9 additions & 7 deletions ktrain/lroptimize/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,16 @@ def __call__(self, gradients):
_ = self.step # Create the step variable.
self._gradients.extend(
[
tf.Variable(
tf.zeros_like(gradient),
trainable=False,
synchronization=tf.VariableSynchronization.ON_READ,
aggregation=tf.VariableAggregation.ONLY_FIRST_REPLICA,
(
tf.Variable(
tf.zeros_like(gradient),
trainable=False,
synchronization=tf.VariableSynchronization.ON_READ,
aggregation=tf.VariableAggregation.ONLY_FIRST_REPLICA,
)
if gradient is not None
else gradient
)
if gradient is not None
else gradient
for gradient in gradients
]
)
Expand Down
1 change: 1 addition & 0 deletions ktrain/text/ner/anago/callbacks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Custom callbacks.
"""

from ....imports import *
from .. import metrics

Expand Down
1 change: 1 addition & 0 deletions ktrain/text/ner/anago/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Model definition.
"""

from .... import utils as U
from ....imports import *

Expand Down
1 change: 1 addition & 0 deletions ktrain/text/ner/anago/tagger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Model API.
"""

from ....imports import *
from .. import metrics

Expand Down
1 change: 0 additions & 1 deletion ktrain/text/ner/anago/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Utility functions.
"""


from ....imports import *


Expand Down
8 changes: 5 additions & 3 deletions ktrain/text/qa/qa_finetuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ def convert_dataset_for_tensorflow(

def densify_ragged_batch(features, label=None):
features = {
feature: ragged_tensor.to_tensor(shape=batch_shape[feature])
if feature in tensor_keys
else ragged_tensor
feature: (
ragged_tensor.to_tensor(shape=batch_shape[feature])
if feature in tensor_keys
else ragged_tensor
)
for feature, ragged_tensor in features.items()
}
if label is None:
Expand Down

0 comments on commit 89343ce

Please sign in to comment.