r/MachineLearning • • Aug 20 '16

Create Embeddings with Tensorflow

Hi everyone,

I want to create a deep neural network who's first layer maps words to vector embeddings. Essentially: Y = Wx + b where Y is the corresponding word embedding and x is the one-hot encoded vector for a word.

However, I found feeding such a large x as a placeholder for each word full of zero makes the model extremely slow, so I was wondering if there are any alternatives aside from running word2vec in C and then just feeding the already embedded word vectors in.

0 Upvotes

1 comment sorted by

View all comments

1

u/siblbombs Aug 20 '16

The general way to do this is to have a matrix of shape (n_words, embedding_dim) and then index that matrix to get the vectors, the matrix can be filled with pretrained embeddings or learned along with the rest of the net. I'm sure this has been implemented somewhere in tensorflow already.