Dmytro Nalyvaiko
Dmytro Nalyvaiko

Reputation: 1824

How to use learned word2vec in keras/tensorflow?

I want to classify 2 types of sentences: statements and questions. For this I need already learned word2vec NN to pass sentences throw it and receive 2d array for each sentence, e.g.:

[[~300 items], [~300 items], [~300 items], ...]

"300" is approximated length of word vector.

how to do that is keras? what library is better to use?

Upvotes: 2

Views: 1038

Answers (1)

Marcin Możejko
Marcin Możejko

Reputation: 40516

What I adivce you is to use an Embedding layer and set its weights:

input = Input(shape=(seq_len,))
embedding = Embedding(input_dim=vocabulary_size, 
    output_dim=300, weights=[your_w2v_matrix])(input)
...

Here you could find a really similiar question.

Upvotes: 1

Related Questions