Skip to content

Commit

Permalink
RF label_smoothed_log_prob_gradient, efficient no-op case
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Jul 13, 2024
1 parent 56a01b9 commit 90f56c9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions returnn/frontend/label_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def label_smoothed_log_prob_gradient(
= softmax(z)[j] - target_prob[j] # assuming (sum_i target_prob[i]) == 1
"""
if not isinstance(smoothing, Tensor) and smoothing == 0:
return log_prob # no-op
if not axis:
assert log_prob.feature_dim
axis = log_prob.feature_dim
Expand Down

0 comments on commit 90f56c9

Please sign in to comment.