From 81fcc9cb725acbe452d28135ae12a04a5a3e68ea Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Wed, 1 Sep 2021 19:36:28 +0800 Subject: [PATCH] fix label smooth bug (#1191) --- ppcls/loss/celoss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppcls/loss/celoss.py b/ppcls/loss/celoss.py index 7bc3c06c..134797fb 100644 --- a/ppcls/loss/celoss.py +++ b/ppcls/loss/celoss.py @@ -29,7 +29,7 @@ class CELoss(nn.Layer): self.epsilon = epsilon def _labelsmoothing(self, target, class_num): - if target.shape[-1] != class_num: + if target.ndim == 1 or target.shape[-1] != class_num: one_hot_target = F.one_hot(target, class_num) else: one_hot_target = target -- GitLab