Giter Club home page Giter Club logo

Comments (4)

 avatar commented on May 18, 2024

Sorry,maybe I have not described this problem clearly.
For example,I have a label set {"label1":1,"label2":2},so the function size returns 3 cause of the length of instance is 2.
When use_crf=False,

# add two more label for downlayer lstm, use original label size for CRF
label_size = data.label_alphabet_size
data.label_alphabet_size += 2
# so the hidden2tag 
self.hidden2tag = nn.Linear(data.HP_hidden_dim, data.label_alphabet_size)

the output size of hidden2tag is 5,
when use _, tag_seq = torch.max(outs, 1),the result maybe 0-4,but the label alphabe only has two labels,index 1 and index 2.
Thank you.

from ncrfpp.

jiesutd avatar jiesutd commented on May 18, 2024

I think I get your point. I also had this concern during writing this framework.

The "START" and "END" is for the CRF calculation. In the CRF layer, I set some of the default transition scores to -10000 to avoid the "START" and "END" output.

To keep the code simple, the "START" and "END" are also added in the model with softmax output. Theoretically, the model may decode some invalid labels "START/END" but it is almost impossible in real data. When the model is trained with the training data, it will not decode the invalid labels as they do not exist in the training data.

from ncrfpp.

 avatar commented on May 18, 2024

Thank you.
In other words,once after training,the _, tag_seq = torch.max(outs, 1) almost will not produce invalid output.

from ncrfpp.

jiesutd avatar jiesutd commented on May 18, 2024

Exactly!

from ncrfpp.

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.