Skip to content

Commit e69d9c8

Browse files
Bai Yifanqingqing01
authored andcommitted
code fix (#13365)
1 parent ae67dce commit e69d9c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

paddle/fluid/operators/softmax_with_cross_entropy_op.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ __global__ void CrossEntropyGrad(T* logit_grad, const int64_t* labels,
3131
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < batch_size;
3232
i += blockDim.x * gridDim.x) {
3333
int idx = i * class_num + labels[i];
34-
logit_grad[idx] -= static_cast<T>(1.);
34+
logit_grad[idx] -=
35+
ignore_index == labels[i] ? static_cast<T>(0.) : static_cast<T>(1.);
3536
}
3637
}
3738

0 commit comments

Comments
 (0)