Reputation: 421
I am trying to use word2vec for a project and after training I get:
INFO : not storing attribute syn0norm
Is there any way I could save the syn0norm
.
How can I do so?
Upvotes: 3
Views: 4251
Reputation: 454
This is fine -- you shouldn't need to store the array syn0norm.
It's computed in the init_sims procedure, and only on an as needed basis. After training, it's actually not defined so there's nothing to train.
When you query the model (such as most_similar), it will call init_sims which checks to see if syn0norm is defined. If not it assigns it with the following line:
self.syn0norm = (self.syn0 / sqrt((self.syn0 ** 2).sum(-1))[..., newaxis]).astype(REAL)
EDIT:
After looking through code (for other things) I see that you can specify if you want to save syn0norm -- there's an ignore setting which defaults to ['syn0norm'], so the following will save all:
In [239]: model.save('test',ignore=[])
2015-03-17 09:07:54,733 : INFO : saving Word2Vec object under test, separately None
2015-03-17 09:07:54,734 : INFO : storing numpy array 'syn0' to test.syn0.npy
2015-03-17 09:08:15,908 : INFO : storing numpy array 'table' to test.table.npy
2015-03-17 09:08:17,908 : INFO : storing numpy array 'syn1neg' to test.syn1neg.npy
2015-03-17 09:08:35,037 : INFO : storing numpy array 'syn1' to test.syn1.npy
2015-03-17 09:09:03,766 : INFO : storing numpy array 'syn0norm' to test.syn0norm.npy
The problem is, it usually will take less time to calculate than save and reload.
Upvotes: 3