Skip to content

Commit c0f7245

Browse files
committed
Change label smoothing to 0.1
1 parent 98a60b5 commit c0f7245

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fast_plate_ocr/model/custom.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def top_3_k(y_true, y_pred):
6161

6262

6363
# Custom loss
64-
def cce_loss(vocabulary_size: int):
64+
def cce_loss(vocabulary_size: int, label_smoothing: float = 0.1):
6565
"""
6666
Categorical cross-entropy loss.
6767
"""
@@ -73,7 +73,9 @@ def cce(y_true, y_pred):
7373
y_true = ops.reshape(y_true, newshape=(-1, vocabulary_size))
7474
y_pred = ops.reshape(y_pred, newshape=(-1, vocabulary_size))
7575
return ops.mean(
76-
losses.categorical_crossentropy(y_true, y_pred, from_logits=False, label_smoothing=0.2)
76+
losses.categorical_crossentropy(
77+
y_true, y_pred, from_logits=False, label_smoothing=label_smoothing
78+
)
7779
)
7880

7981
return cce

0 commit comments

Comments
 (0)