sentence2vec icon indicating copy to clipboard operation
sentence2vec copied to clipboard

I meet a problem

Open hit-joseph opened this issue 8 years ago • 3 comments

the problem I met is as follows: Traceback (most recent call last): File "/home/joyous-yim/pycode/sentence2vec-master/spacy_sentence2vec_demo.py", line 63, in

sentence_vectors = sentence_to_vec(sentence_list, embedding_size) # all vectors converted together File "/home/joyous-yim/pycode/sentence2vec-master/sentence2vec.py", line 80, in sentence_to_vec pca.fit(np.array(sentence_set)) File "/home/joyous-yim/anaconda3/envs/sentence2vec-master/lib/python3.6/site-packages/sklearn/decomposition/pca.py", line 340, in fit self._fit(X) File "/home/joyous-yim/anaconda3/envs/sentence2vec-master/lib/python3.6/site-packages/sklearn/decomposition/pca.py", line 407, in _fit return self._fit_full(X, n_components) File "/home/joyous-yim/anaconda3/envs/sentence2vec-master/lib/python3.6/site-packages/sklearn/decomposition/pca.py", line 426, in _fit_full % (n_components, min(n_samples, n_features))) ValueError: n_components=300 must be between 0 and min(n_samples, n_features)=12 with svd_solver='full'

can you help me? hope for your reply.

hit-joseph avatar Nov 23 '18 08:11 hit-joseph

strange - the line number doesn't match (sentence_to_vec() is on line 79, not line 80) - however - it looks from the error message like the sentence vectors you're passing in are size 12, and not 300?

rock3125 avatar Nov 23 '18 09:11 rock3125

strange - the line number doesn't match (sentence_to_vec() is on line 79, not line 80) - however - it looks from the error message like the sentence vectors you're passing in are size 12, and not 300? I add a print line before the error line ,so the line number is 80 not 79. and I check the error line : pca.fit(np.array(sentence_set)) be sure of that senterce_set I passing in are shape(12,300), Is there any wrong with it?

hit-joseph avatar Nov 26 '18 07:11 hit-joseph

hey dude - there is indeed a problem with the sizes. Perhaps they changed sklearn? Anyway -I've fixed it. I got the same error you did, and have changed the code so it runs like it did before. Have fun!!

rock3125 avatar Nov 26 '18 08:11 rock3125