Git Product home page Git Product logo

continuous-bag-of-words-pytorch's Introduction

continuous-bag-of-words(CBOW)-pytorch

This is one of the implementation of CBOW model in pytorch lib. CBOW is used for learning the word(getting the word probability) by looking at the context. A single window was define for words context learnig. One of the objectives of CBOW model is to find two words similirity. Nowadays CBOW is frequently used in many NLP deep learning task.

RUN

python3 cbow_model_pytorch.py 

it will verbose all training loss. test_cbow function used to show the two words similarity after learning the corpus context.

continuous-bag-of-words-pytorch's People

Contributors

smafjal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

continuous-bag-of-words-pytorch's Issues

You may have made a mistake in your forward().

Your implementation:

def forward(self, inp):
        out = self.embeddings(inp).view(1, -1)
        out = out.view(1, -1)
        out = self.lin1(out)
        out = F.relu(out)
        out = self.lin2(out)
        out = F.log_softmax(out, dim=1)
        return out

However, you need to sum embeddings as the formula:
$ logp(w_i|C)= logSoftmax(A(\sum_{wโˆˆC}q_w)+b)$

i.e

def forward(self, inp):
        out = torch.sum(self.embeddings(inp), dim=0).view(1, -1)
        .....

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.