Giter Site home page Giter Site logo

nplm's Introduction

This is an implementation of a Feedforward neural network for building a language model. Though, I took inspiration from Y. Bengio's 2003 classic paper published in JMLR : "A Neural Probabilistic Language Model", I tweaked the word embeddings generation procedure to the current SOTA method : skip-gram model with Noise Contrastive Estimation.

I have also employed the use of Xavier algorithm to initialize weights of the neural network. It determines the variance of the distribution of the weights based on the number of input and output neurons. It helps to propagate the signal deep into the network. This is because if the weights are initialized with a small value, it starts to diminish as it passes through layers and drops off to a really low value. Considering the activation function to be sigmoid, the low value of input makes the activations almost linear which beats the point of introducing non-linearity in the network. Vice versa, in the case the weights are initialized with a large value, the variance of input increases with each passing layer. Eventually, the activations again become linear since sigmoid function becomes flat for large values. Hence the need to initialize the weights with the right amount of variance :

Var(Wi) = 2 / (Ninp + Nout)      

where Ninp = number of input neurons and Nout = number of output neurons. The variance of weights is set to this value in order to equalize the variance of output and input to a linear neuron (Y = W1X1 + .... + WnXn) per layer (kindly check the paper for detailed description).

I am using TensorFlow for generating the word embeddings as well as for the language model. At the time, I wrote this code, the latest version was 1.3!

Corpus:

As of now, I am using a basic text corpus of a synopsis of a movie.

nplm's People

Contributors

greninja avatar

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.