LoginSignup
0
1

More than 1 year has passed since last update.

単語の分散表現の学習

Posted at

はじめに

※単語の分散表現の学習のためのメモです。
※編集する時間がないので主に自分用のメモです。

用意するもの

コーパス

日本語のwikipediaで学習したコーパスを使います。下記のリンク先からインストールしてください。
ja.text8

ステップ1.gensimのインストール

pythonインタプリタ
conda install gensim 

ステップ2.必要な機能のインストール

pythonインタプリタ
import logging
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s',level-logging.INFO) 
sentences = TextCorpus('data/ja.text8')

ステップ3.モデルの学習

pythonインタプリタ
model = Word2Vec(sentences, size=100, window=5, sg=1)
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s',level-logging.INFO) 
sentences = TextCorpus('data/ja.text8')

ステップ4.モデルのセーブと読み込み

モデルのセーブ

pythonインタプリタ
model.save('models/model.bin')

 モデルの読み込み

pythonインタプリタ
model = Word2Vec.load('models/model.bin')
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1