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.

About embedding_weights

See original GitHub issue

First, thank you for code sharing.

In w2v.py, I saw your code as follows:

 embedding_weights = [np.array([embedding_model[w] if w in embedding_model
                  else np.random.uniform(-0.25, 0.25, embedding_model.vector_size)
                  for w in vocabulary_inv])]

For obtaining weights from embedding_model, parameter w must be a word, e.g. “happy”. But, in w2v.py, "for w in embedding_model ", w is an index of word

Is that a mistake here? The code “else np.random.uniform(-0.25, 0.25, embedding_model.vector_size)” seems been executed in every loop.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-rakhlincommented, May 31, 2017

Looks okay. embedding_weights must be a list of len=1 of ndarray with shape=(len(vocabulary_inv), num_features). It was made a list for compatibility with keras layer.set_weights()

0reactions
alexander-rakhlincommented, Jun 8, 2017

Please see updated version

Read more comments on GitHub >

github_iconTop Results From Across the Web

Embedding — PyTorch 1.13 documentation
Creates Embedding instance from given 2-dimensional FloatTensor. Parameters: embeddings (Tensor) – FloatTensor containing weights for the Embedding. First ...
Read more >
Understanding Embedding Layer in Keras - Medium
Once the training is completed, embedding layer has learnt the weights which are nothing but the vector representations of each word. Lets check ......
Read more >
Neural Network Embeddings Explained - Towards Data Science
The embeddings form the parameters — weights — of the network which are adjusted to minimize loss on the task.
Read more >
Embedding layer - Keras
Embedding class. Turns positive integers (indexes) into dense vectors of fixed size. This layer can only be used on positive integer inputs of...
Read more >
What does a weighted word embedding mean? - Stack Overflow
1). The second represents a sentence by averaging the word embeddings of all words (in the sentence) and the third represents a sentence...
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