Skip to content

Commit 9e03215

Browse files
authored
[FIX]: add default triplet metric name to avoid None
1 parent 1c6615d commit 9e03215

File tree

1 file changed

+5
-2
lines changed
  • T-LBO/weighted_retraining/weighted_retraining

1 file changed

+5
-2
lines changed

T-LBO/weighted_retraining/weighted_retraining/metrics.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,16 @@ def __call__(self, embs: Tensor, ys: Tensor):
144144
@staticmethod
145145
def exp_metric_id(threshold: float, margin: Optional[float] = None, soft: Optional[bool] = None,
146146
eta: Optional[bool] = None) -> str:
147+
metric_id_base = f'triplet-thr-{threshold:g}'
147148
if margin is not None:
148-
return f'triplet-thr-{threshold:g}-mrg-{margin:g}'
149+
return f'{metric_id_base}-mrg-{margin:g}'
149150
if soft is not None:
150-
metric_id = f'triplet-thr-{threshold:g}-soft'
151+
metric_id = f'{metric_id_base}-soft'
151152
if eta is not None:
152153
metric_id += f'-eta-{eta:g}'
153154
return metric_id
155+
else:
156+
return metric_id_base
154157

155158

156159
class LogRatioLossTorch:

0 commit comments

Comments
 (0)