Skip to content

Commit f985e60

Browse files
committed
formatted code
1 parent 4292796 commit f985e60

File tree

8 files changed

+16
-7
lines changed

8 files changed

+16
-7
lines changed

src/pytorch_metric_learning/datasets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .cars196 import Cars196
33
from .cub import CUB
44
from .inaturalist2018 import INaturalist2018
5-
from .sop import StanfordOnlineProducts
5+
from .sop import StanfordOnlineProducts

src/pytorch_metric_learning/losses/generic_pair_loss.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def pair_based_loss(self, mat, indices_tuple):
3939
if len(a2) > 0:
4040
neg_pair = mat[a2, n]
4141
return self._compute_loss(pos_pair, neg_pair, indices_tuple)
42-
42+
4343
@staticmethod
4444
def _assert_either_pos_or_neg(pos_mask, neg_mask):
45-
assert not torch.any((pos_mask != 0) & (neg_mask != 0)), "Each pair should be either be positive or negative"
45+
assert not torch.any(
46+
(pos_mask != 0) & (neg_mask != 0)
47+
), "Each pair should be either be positive or negative"

src/pytorch_metric_learning/losses/subcenter_arcface_loss.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ def __init__(self, *args, margin=28.6, scale=64, sub_centers=3, **kwargs):
1919
del kwargs["num_classes"]
2020
del kwargs["embedding_size"]
2121
super().__init__(
22-
num_classes=num_classes * sub_centers, embedding_size=embedding_size, margin=margin, scale=scale, **kwargs
22+
num_classes=num_classes * sub_centers,
23+
embedding_size=embedding_size,
24+
margin=margin,
25+
scale=scale,
26+
**kwargs
2327
)
2428
self.sub_centers = sub_centers
2529
self.num_classes = num_classes

tests/datasets/test_cars196.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from torch.utils.data import DataLoader
77

88
from pytorch_metric_learning.datasets import Cars196
9+
910
from .. import TEST_DATASETS
1011

1112

tests/datasets/test_cub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from torch.utils.data import DataLoader
77

88
from pytorch_metric_learning.datasets import CUB
9+
910
from .. import TEST_DATASETS
1011

1112

tests/datasets/test_inaturalist2018.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from torch.utils.data import DataLoader
77

88
from pytorch_metric_learning.datasets import INaturalist2018
9+
910
from .. import TEST_DATASETS
1011

1112

tests/datasets/test_sop.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from torch.utils.data import DataLoader
77

88
from pytorch_metric_learning.datasets import StanfordOnlineProducts
9+
910
from .. import TEST_DATASETS
1011

1112

tests/losses/test_subcenter_arcface_loss.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,9 @@ def test_reducer_subcenter_arcface(self):
152152
embedding_size=64,
153153
reducer=DoNothingReducer(),
154154
)
155-
155+
156156
emb = torch.randn(4, 64)
157157
result = arcfaceloss(emb, torch.arange(4))
158158

159159
self.assertTrue(isinstance(result, dict))
160-
self.assertTrue(result['loss']['losses'].shape[0] == 4)
161-
160+
self.assertTrue(result["loss"]["losses"].shape[0] == 4)

0 commit comments

Comments
 (0)