Git Product home page Git Product logo

Comments (4)

csukuangfj avatar csukuangfj commented on June 20, 2024 1

By the way, you can replace ctc_loss != float('inf') with

torch.isinf(ctc_loss)

from icefall.

csukuangfj avatar csukuangfj commented on June 20, 2024

The minimum of number frames (before subsampling) is 11.

If you are using conformer_ctc, which has a subsampling factor of 4, you will get ( (11 - 1) / 2 - 1) / 2 = 2 frames.
One of the assumptions of CTC is that the output label length is not greater than that of the input length.
If that assumption does not hold, you will get an empty lattice, and hence an inf value for the total score.

And what is the recommended minimum threshold for this value?

You can do one of the following:

  • (1) Exclude inf values from ctc loss
    ctc_loss = k2.ctc_loss(
    decoding_graph=decoding_graph,
    dense_fsa_vec=dense_fsa_vec,
    output_beam=params.beam_size,
    reduction=params.reduction,
    use_double_scores=params.use_double_scores,
    )

(Note you have to first set params.reduction to none, filter inf values from ctc_loss, and then compute the sum.

  • (2) Filter utterances that are too short from the manifest.

from icefall.

tz301 avatar tz301 commented on June 20, 2024

Thanks, I will try to simply filter short utterances and adjust some threshold for experiments.

from icefall.

AmirHussein96 avatar AmirHussein96 commented on June 20, 2024

My solution:

ctc_loss = k2.ctc_loss(decoding_graph=decoding_graph, 
dense_fsa_vec=dense_fsa_vec,
output_beam=params.beam_size,
reduction='none',
use_double_scores=params.use_double_scores,
    )

#filter inf when performing sum reduction with ctc_loss
ctc_loss = torch.sum(torch.where(ctc_loss != float('inf'),ctc_loss , torch.tensor(0, dtype=torch.float32).to(device)))

from icefall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.