概要
Facebook ResearchがfastTextよりも早く学習ができると噂のものを出していた(2017/10)ので、お試し。
とりあえずやってみる
requirements!
コンパイルの必要があるため、以下のライブラリがあるか確認する。
要するに「make」が走れば良さげ。
(gcc-4.6.3 or newer) or (clang-3.3 or newer)
また、Boost ライブラリといふものも必要となる。
ドキュメントの文章を翻訳すると多分以下の感じ。
StarSpaceを実行するには、Boostライブラリをインストールし、makefileにboostライブラリのパスを指定する必要があります
もしboostのインストールを怠ってmakeすると
Errorが出るのだ
oki.suguru$ make
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/utils/normalize.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/dict.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/utils/args.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/proj.cpp
In file included from src/proj.cpp:11:
In file included from src/proj.h:14:
src/matrix.h:26:10: fatal error: 'boost/numeric/ublas/matrix.hpp' file not found
#include <boost/numeric/ublas/matrix.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [proj.o] Error 1
なんだこれ・・・なんかFatal Error出たぞ・・・となる。
Boostライブラリのインストール
Boostライブラリのインストール(Mac)
$ brew install boost
Boostライブラリのインストール(Mac以外)
$wget https://dl.bintray.com/boostorg/release/1.63.0/source/boost_1_63_0.zip
$unzip boost_1_63_0.zip
$sudo mv boost_1_63_0 /usr/local/bin
オプション:srcディレクトリで単体テストを実行する場合は、google testが必要であり、そのパスをmakefileの 'TEST_INCLUDES'に指定する必要があります。
なぜboostが必要か
github Issueをみてみると、Boostの依存関係がまだ解決されていないとのこと。
inputファイルないけど、とりあえず実行
oki.suguru$ ./starspace train -trainFile data.txt -model modelSaveFile
Arguments:
lr: 0.01
dim: 100
epoch: 5
maxTrainTime: 8640000
saveEveryEpoch: 0
loss: hinge
margin: 0.05
similarity: cosine
maxNegSamples: 10
negSearchLimit: 50
thread: 10
minCount: 1
minCountLabel: 1
label: __label__
ngrams: 1
bucket: 2000000
adagrad: 1
trainMode: 0
fileFormat: fastText
normalizeText: 0
dropoutLHS: 0
dropoutRHS: 0
Start to initialize starspace model.
Build dict from input file : data.txt
Input file cannot be opened!
まあ、そうですな!
なので、exampleフォルダのwikipedia_article_search.shをコピーして実行してみた。
StarSpace/examples
oki.suguru$ cp wikipedia_article_search.sh ../wikipedia_article_search.sh
oki.suguru$ ./wikipedia_article_search.sh
Arguments:
lr: 0.05
dim: 100
epoch: 5
maxTrainTime: 8640000
saveEveryEpoch: 0
loss: hinge
margin: 0.05
similarity: cosine
maxNegSamples: 3
negSearchLimit: 5
thread: 20
minCount: 5
minCountLabel: 1
label: __label__
ngrams: 1
bucket: 2000000
adagrad: 1
trainMode: 2
fileFormat: labelDoc
normalizeText: 1
dropoutLHS: 0
dropoutRHS: 0.8
Start to initialize starspace model.
Build dict from input file : /tmp/starspace/data/wikipedia_train250k.txt
Read 104M words
Number of words in dictionary: 267523
Number of labels in dictionary: 0
Loading data from file : /tmp/starspace/data/wikipedia_train250k.txt
Total number of examples loaded : 241744
Initialized model weights. Model size :
matrix : 267523 100
Training epoch 0: 0.05 0.01
Epoch: 30.6% lr: 0.046930 loss: 0.028636 eta: 0h18m tot: 0h1m10s (6.1%)^C
熱量の排気が間に合わなかったので、途中で中断。
結果は後日また追記。