question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why gradient does not scale linearly with CTCloss?

See original GitHub issue

I am trying to use CTCLoss with another loss, and want coefficients of CTCLoss smaller. But when I tried different

This is the extreme cases for small CTCLoss. (CTCLoss coefficient = 0)

criterion = CTCLoss()
loss = 0*criterion(out, targets, sizes, target_sizes)
model.zero_grad()
loss.backward()
optimizer.step()

for param in model.parameters():
     if param.grad is not None:
          grad_norm += param.grad.norm().data[0]

In above example, loss is always 0. However, fairly large gradient value still exists even CTCLoss coefficient is 0.

Can anyone explain why gradient does not scale linearly with CTCLoss?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jinserkcommented, Oct 23, 2018

nn.CTCLoss doesn’t have the softmax in it. We need to give an explicit log softmax of the input probs to it. I’ve tested but this isn’t making the difference. I guess the most difference was happened by the gradient connection in backward()

0reactions
stale[bot]commented, Feb 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Why gradient does not scale linearly with CTCloss? -
I am trying to use CTCLoss with another loss, and want coefficients of CTCLoss smaller. But when I tried different. This is the...
Read more >
CTCLoss performance of PyTorch 1.0.0 - #39 by phtephanx - nlp
My acoustic model does not converge using the nn.CTCLoss function. The model used 4 BiLSTM layers and one linear layer. When I looked...
Read more >
BEN CHEN's Homepage - ctc loss - Google Sites
Sometimes, the calculated ctc loss has an infinity element and infinity gradient. This is common when the input sequence is not too much...
Read more >
Sequence Modeling with CTC - Distill.pub
The CTC loss function is differentiable with respect to the per time-step output probabilities since it's just sums and products of them. Given ......
Read more >
Scaling DeepSpeech using Mixed Precision and KubeFlow
A crucial portion of our audio pipeline is our automatic speech recognition ... dynamic loss scaling was crucial to ensure that our gradients...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found