Skip to content

Commit

Permalink
fix incorrect default argument
Browse files Browse the repository at this point in the history
  • Loading branch information
rbracco committed Aug 19, 2020
1 parent 90a8b5c commit 9b5179d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ beam_results, beam_scores, timesteps, out_lens = decoder.decode(output)
This is an important parameter that represents a tradeoff you need to make based on your dataset and needs.
- `num_processes` Parallelize the batch using num_processes workers. You probably want to pass the number of cpus your computer has. You can find this in python with `import multiprocessing` then `n_cpus = multiprocessing.cpu_count()`. Default 4.
- `blank_id` This should be the index of the blank token (probably 0) used when training your model so that ctcdecode can remove it during decoding.
- `log_probs_input` If your outputs have passed through a softmax and represent probabilities, this should be false, if they passed through a LogSoftmax and represent negative log likelihood, you need to pass True. If you don't understand this, run `print(output[0][0].sum())`, if it's a negative number you've probably got NLL and need to pass True, if it sums to ~1.0 you should pass False. Default True.
- `log_probs_input` If your outputs have passed through a softmax and represent probabilities, this should be false, if they passed through a LogSoftmax and represent negative log likelihood, you need to pass True. If you don't understand this, run `print(output[0][0].sum())`, if it's a negative number you've probably got NLL and need to pass True, if it sums to ~1.0 you should pass False. Default False.

### Inputs to the `decode` method
- `output` should be the output activations from your model. If your output has passed through a SoftMax layer, you shouldn't need to alter it (except maybe to transpose), but if your `output` represents negative log likelihoods (raw logits), you either need to pass it through an additional `torch.nn.functional.softmax` or you can pass `log_probs_input=False` to the decoder. Your output should be BATCHSIZE x N_TIMESTEPS x N_LABELS so you may need to transpose it before passing it to the decoder. Note that if you pass things in the wrong order, the beam search will probably still run, you'll just get back nonsense results.
Expand All @@ -78,6 +78,7 @@ for i in range(50):
Note, these will be a list of ints that need decoding. You likely already have a function to decode from int to text, but if not you can do something like.
`"".join[labels[n] for n in beam_results[0][0][:out_len[0][0]]]` using the labels you passed in to `CTCBeamDecoder`


## Resources

- [Distill Guide to CTC](https://distill.pub/2017/ctc/)
Expand Down

0 comments on commit 9b5179d

Please sign in to comment.