model = Word2Vec.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)
में Gensim लाइब्रेरी का उपयोग करके शब्द वैक्टर हो रही मॉडल लोड हो रहा है मैं वैक्टर
#reading all sentences from training file
with open('restaurantSentences', 'r') as infile:
x_train = infile.readlines()
#cleaning sentences
x_train = [review_to_wordlist(review,remove_stopwords=True) for review in x_train]
train_vecs = np.concatenate([buildWordVector(z, n_dim) for z in x_train])
में प्रशिक्षण समीक्षा की सजा शब्द परिवर्तित कर रहा हूँ word2Vec के दौरान के बाद के लिए पूर्व प्रशिक्षित गूगल समाचार डाटासेट उपयोग कर रहा हूँ प्रक्रिया मुझे अपने कॉर्पस में शब्दों के लिए बहुत सारी त्रुटियां मिलती हैं, जो मॉडल में नहीं हैं। समस्या यह है कि मैं उन लापता शब्दों के लिए शब्द वैक्टर प्राप्त करने के लिए पहले से ही पूर्व-प्रशिक्षित मॉडल (जैसे GoogleNews-vectors-negative300.bin ') को कैसे रोक सकता हूं।
के बाद मैं क्या करने की कोशिश की है: कि मैं
# Set values for various parameters
num_features = 300 # Word vector dimensionality
min_word_count = 10 # Minimum word count
num_workers = 4 # Number of threads to run in parallel
context = 10 # Context window size
downsampling = 1e-3 # Downsample setting for frequent words
sentences = gensim.models.word2vec.LineSentence("restaurantSentences")
# Initialize and train the model (this will take some time)
print "Training model..."
model = gensim.models.Word2Vec(sentences, workers=num_workers,size=num_features, min_count = min_word_count,
window = context, sample = downsampling)
model.build_vocab(sentences)
model.train(sentences)
model.n_similarity(["food"], ["rice"])
यह काम किया था प्रशिक्षण वाक्य से एक नया मॉडल प्रशिक्षित! लेकिन समस्या यह है कि मेरे पास एक बड़े मॉडल को प्रशिक्षित करने के लिए वास्तव में एक छोटा डेटासेट और कम संसाधन है।
दूसरा तरीका जो मैं देख रहा हूं वह पहले से ही प्रशिक्षित मॉडल जैसे GoogleNews-vectors-negative300.bin का विस्तार करना है।
model = Word2Vec.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)
sentences = gensim.models.word2vec.LineSentence("restaurantSentences")
model.train(sentences)
क्या यह संभव है और यह एक अच्छी तरह से उपयोग करने के लिए है, मुझे बाहर करने में मदद
[अद्यतन gensim word2vec मॉडल] के अद्यतन डुप्लिकेट (http://stackoverflow.com/questions/22121028/update-gensim-word2vec-model) – ksindi