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.

[Question] Actual usage examples?

See original GitHub issue

Besides the toy examples listed in the docs and tests, are there actual examples of this library available anywhere?

I’m interested in using this library for a sequence labeling project, but I’m curious to know if I’m using this library correctly. What I have is something like this:

class MyModel(nn.Module):
    def __init__(self, num_features, num_classes):
        super(MyModel, self).__init__()
        self.num_features = num_features
        self.num_classes = num_classes
        self.lstm = nn.LSTM(num_features, 128)
        self.fc = nn.Linear(128, num_classes)
        self.crf = CRF(num_classes)

# ----------------------------------------------------------
model = MyModel(...)

# Training loop:
y_hat = model(batch)  # The network's forward returns fc(lstm(batch))
loss = -model.crf(y_hat, y)
loss.backward()
optimizer.step()

Although this seems to work and the loss is decreasing, I have a feeling that I might be missing something. Any help is appreciated. Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Maghoumicommented, Feb 21, 2019

It may be helpful to provide such loss class for those who are more comfortable with this pattern such as yourself. Thanks for bringing this up.

No problem! That would be an excellent idea. Also thanks for clarification regarding the log_softmax() bit.

Feel free to close this issue, or keep it open as a reminder if you decide to incorporate more examples and also change the library such that loss is separate from the CRF’s output. I’d personally be very happy if the changes/examples are added.
Also, thanks for the great library!

0reactions
kmkurncommented, Jun 13, 2019

@Huijun-Cui Thanks for letting me know. Next time please open a separate issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The 4 Main Types of Questions in English + Examples - Preply
4 Types of Questions in English. In this section, we'll walk you through each question type and provide real-world examples.
Read more >
over 70 survey question examples + types of surveys and FAQs
70+ survey question examples you can use. Dos and don'ts of writing survey questions. 10 survey use cases: what you can do with...
Read more >
User Interview Example Questions
The following are sample questions for a user interview. Please note that your questions need to be tailored to each individual project.
Read more >
Question Definition & Meaning - Merriam-Webster
The meaning of QUESTION is an interrogative expression often used to test knowledge. How to use question in a sentence.
Read more >
Survey Questions: Tips & Examples in 2022 - Qualtrics
Use open-ended question structures like “How do you feel about…” “If you said x, why?” or “What makes a good x?” Open-ended questions...
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