Python/Gensim - What is the meaning of syn0 and syn0norm?
up vote
0
down vote
favorite
I know that in gensims KeyedVectors
-model, one can access the embedding matrix by the attribute model.syn0
. There is also a syn0norm
, which doesn't seem to work for the glove model I recently loaded. I think I also have seen syn1
somewhere previously.
I haven't found a doc-string for this and I'm just wondering what's the logic behind this?
So if syn0
is the embedding matrix, what is syn0norm
? What would then syn1
be and generally, what does syn
stand for?
python deep-learning nlp gensim word-embedding
add a comment |
up vote
0
down vote
favorite
I know that in gensims KeyedVectors
-model, one can access the embedding matrix by the attribute model.syn0
. There is also a syn0norm
, which doesn't seem to work for the glove model I recently loaded. I think I also have seen syn1
somewhere previously.
I haven't found a doc-string for this and I'm just wondering what's the logic behind this?
So if syn0
is the embedding matrix, what is syn0norm
? What would then syn1
be and generally, what does syn
stand for?
python deep-learning nlp gensim word-embedding
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I know that in gensims KeyedVectors
-model, one can access the embedding matrix by the attribute model.syn0
. There is also a syn0norm
, which doesn't seem to work for the glove model I recently loaded. I think I also have seen syn1
somewhere previously.
I haven't found a doc-string for this and I'm just wondering what's the logic behind this?
So if syn0
is the embedding matrix, what is syn0norm
? What would then syn1
be and generally, what does syn
stand for?
python deep-learning nlp gensim word-embedding
I know that in gensims KeyedVectors
-model, one can access the embedding matrix by the attribute model.syn0
. There is also a syn0norm
, which doesn't seem to work for the glove model I recently loaded. I think I also have seen syn1
somewhere previously.
I haven't found a doc-string for this and I'm just wondering what's the logic behind this?
So if syn0
is the embedding matrix, what is syn0norm
? What would then syn1
be and generally, what does syn
stand for?
python deep-learning nlp gensim word-embedding
python deep-learning nlp gensim word-embedding
edited Nov 14 at 19:21
asked Nov 14 at 13:56
blue-phoenox
3,66981440
3,66981440
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
These names were inherited from the original Google word2vec.c
implementation, upon which the gensim
Word2Vec
class was based. (I believe syn0
only exists in recent versions for backward-compatbility.)
The syn0
array essentially holds raw word-vectors. From the perspective of the neural-network used to train word-vectors, these vectors are a 'projection layer' that can convert a one-hot encoding of a word into a dense embedding-vector of the right dimensionality.
Similarity operations tend to be done on the unit-normalized versions of the word-vectors. That is, vectors that have all been scaled to have a magnitude of 1.0. (This makes the cosine-similarity calculation easier.) The syn0norm
array is filled with these unit-normalized vectors, the first time they're needed.
This syn0norm
will be empty until either you do an operation (like most_similar()
) that requires it, or you explicitly do an init_sims()
call. If you explicitly do an init_sims(replace=True)
call, you'll actually clobber the raw vectors, in-place, with the unit-normed vectors. This saves the memory that storing both vectors for every word would otherwise require. (However, some word-vector uses may still be interested in the original raw vectors of varying magnitudes, so only do this when you're sure most_similar()
cosine-similarity operations are all you'll need.)
The syn1
(or syn1neg
in the more common case of negative-sampling training) properties, when they exist on a full model (and not for a plain KeyedVectors
object of only word-vectors), are the model neural network's internal 'hidden' weights leading to the output nodes. They're needed during model training, but not a part of the typical word-vectors collected after training.
I believe the syn
prefix is just a convention from neural-network variable-naming, likely derived from 'synapse'.
Great explanation, thank you!
– blue-phoenox
Nov 16 at 7:21
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
These names were inherited from the original Google word2vec.c
implementation, upon which the gensim
Word2Vec
class was based. (I believe syn0
only exists in recent versions for backward-compatbility.)
The syn0
array essentially holds raw word-vectors. From the perspective of the neural-network used to train word-vectors, these vectors are a 'projection layer' that can convert a one-hot encoding of a word into a dense embedding-vector of the right dimensionality.
Similarity operations tend to be done on the unit-normalized versions of the word-vectors. That is, vectors that have all been scaled to have a magnitude of 1.0. (This makes the cosine-similarity calculation easier.) The syn0norm
array is filled with these unit-normalized vectors, the first time they're needed.
This syn0norm
will be empty until either you do an operation (like most_similar()
) that requires it, or you explicitly do an init_sims()
call. If you explicitly do an init_sims(replace=True)
call, you'll actually clobber the raw vectors, in-place, with the unit-normed vectors. This saves the memory that storing both vectors for every word would otherwise require. (However, some word-vector uses may still be interested in the original raw vectors of varying magnitudes, so only do this when you're sure most_similar()
cosine-similarity operations are all you'll need.)
The syn1
(or syn1neg
in the more common case of negative-sampling training) properties, when they exist on a full model (and not for a plain KeyedVectors
object of only word-vectors), are the model neural network's internal 'hidden' weights leading to the output nodes. They're needed during model training, but not a part of the typical word-vectors collected after training.
I believe the syn
prefix is just a convention from neural-network variable-naming, likely derived from 'synapse'.
Great explanation, thank you!
– blue-phoenox
Nov 16 at 7:21
add a comment |
up vote
1
down vote
accepted
These names were inherited from the original Google word2vec.c
implementation, upon which the gensim
Word2Vec
class was based. (I believe syn0
only exists in recent versions for backward-compatbility.)
The syn0
array essentially holds raw word-vectors. From the perspective of the neural-network used to train word-vectors, these vectors are a 'projection layer' that can convert a one-hot encoding of a word into a dense embedding-vector of the right dimensionality.
Similarity operations tend to be done on the unit-normalized versions of the word-vectors. That is, vectors that have all been scaled to have a magnitude of 1.0. (This makes the cosine-similarity calculation easier.) The syn0norm
array is filled with these unit-normalized vectors, the first time they're needed.
This syn0norm
will be empty until either you do an operation (like most_similar()
) that requires it, or you explicitly do an init_sims()
call. If you explicitly do an init_sims(replace=True)
call, you'll actually clobber the raw vectors, in-place, with the unit-normed vectors. This saves the memory that storing both vectors for every word would otherwise require. (However, some word-vector uses may still be interested in the original raw vectors of varying magnitudes, so only do this when you're sure most_similar()
cosine-similarity operations are all you'll need.)
The syn1
(or syn1neg
in the more common case of negative-sampling training) properties, when they exist on a full model (and not for a plain KeyedVectors
object of only word-vectors), are the model neural network's internal 'hidden' weights leading to the output nodes. They're needed during model training, but not a part of the typical word-vectors collected after training.
I believe the syn
prefix is just a convention from neural-network variable-naming, likely derived from 'synapse'.
Great explanation, thank you!
– blue-phoenox
Nov 16 at 7:21
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
These names were inherited from the original Google word2vec.c
implementation, upon which the gensim
Word2Vec
class was based. (I believe syn0
only exists in recent versions for backward-compatbility.)
The syn0
array essentially holds raw word-vectors. From the perspective of the neural-network used to train word-vectors, these vectors are a 'projection layer' that can convert a one-hot encoding of a word into a dense embedding-vector of the right dimensionality.
Similarity operations tend to be done on the unit-normalized versions of the word-vectors. That is, vectors that have all been scaled to have a magnitude of 1.0. (This makes the cosine-similarity calculation easier.) The syn0norm
array is filled with these unit-normalized vectors, the first time they're needed.
This syn0norm
will be empty until either you do an operation (like most_similar()
) that requires it, or you explicitly do an init_sims()
call. If you explicitly do an init_sims(replace=True)
call, you'll actually clobber the raw vectors, in-place, with the unit-normed vectors. This saves the memory that storing both vectors for every word would otherwise require. (However, some word-vector uses may still be interested in the original raw vectors of varying magnitudes, so only do this when you're sure most_similar()
cosine-similarity operations are all you'll need.)
The syn1
(or syn1neg
in the more common case of negative-sampling training) properties, when they exist on a full model (and not for a plain KeyedVectors
object of only word-vectors), are the model neural network's internal 'hidden' weights leading to the output nodes. They're needed during model training, but not a part of the typical word-vectors collected after training.
I believe the syn
prefix is just a convention from neural-network variable-naming, likely derived from 'synapse'.
These names were inherited from the original Google word2vec.c
implementation, upon which the gensim
Word2Vec
class was based. (I believe syn0
only exists in recent versions for backward-compatbility.)
The syn0
array essentially holds raw word-vectors. From the perspective of the neural-network used to train word-vectors, these vectors are a 'projection layer' that can convert a one-hot encoding of a word into a dense embedding-vector of the right dimensionality.
Similarity operations tend to be done on the unit-normalized versions of the word-vectors. That is, vectors that have all been scaled to have a magnitude of 1.0. (This makes the cosine-similarity calculation easier.) The syn0norm
array is filled with these unit-normalized vectors, the first time they're needed.
This syn0norm
will be empty until either you do an operation (like most_similar()
) that requires it, or you explicitly do an init_sims()
call. If you explicitly do an init_sims(replace=True)
call, you'll actually clobber the raw vectors, in-place, with the unit-normed vectors. This saves the memory that storing both vectors for every word would otherwise require. (However, some word-vector uses may still be interested in the original raw vectors of varying magnitudes, so only do this when you're sure most_similar()
cosine-similarity operations are all you'll need.)
The syn1
(or syn1neg
in the more common case of negative-sampling training) properties, when they exist on a full model (and not for a plain KeyedVectors
object of only word-vectors), are the model neural network's internal 'hidden' weights leading to the output nodes. They're needed during model training, but not a part of the typical word-vectors collected after training.
I believe the syn
prefix is just a convention from neural-network variable-naming, likely derived from 'synapse'.
answered Nov 16 at 7:12
gojomo
18.1k64364
18.1k64364
Great explanation, thank you!
– blue-phoenox
Nov 16 at 7:21
add a comment |
Great explanation, thank you!
– blue-phoenox
Nov 16 at 7:21
Great explanation, thank you!
– blue-phoenox
Nov 16 at 7:21
Great explanation, thank you!
– blue-phoenox
Nov 16 at 7:21
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301916%2fpython-gensim-what-is-the-meaning-of-syn0-and-syn0norm%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown