运行 单词相似度手套
Running Word similarity Glove
我已经尝试 运行 我的 Ubuntu 机器上的手套。没关系,直到它给了我以下抱怨 matlab 的错误:
./demo.sh: line 37: matlab: command not found
任何人都可以帮助我如何在我的机器上为 运行 Glove 设置 matlab 吗?
解法一:
matlab命令部分只是glove tool的内在测试部分。
您不需要 运行 demo.sh 的那部分来生成词向量。
解法-2:
此外,随着 GloVe 的新版本 版本 1.2,有 python 代码可以做到这一点。 Matlab 不是必需的,python 会处理它。
demo.sh 有一个 if elif 代码部分,它检查机器上是否存在 matlab 运行ning。如果存在,它 运行s matlab,如果不存在,则检查八度。如果存在八度,则为 运行s 八度。如果八度音阶不存在,它 运行s 与 python。 demo.sh有如下代码,matlab部分是最后一部分:
#!/bin/bash
# Makes programs, downloads sample data, trains a GloVe model, and then evaluates it.
# One optional argument can specify the language used for eval script: matlab, octave or [default] python
make
if [ ! -e text8 ]; then
if hash wget 2>/dev/null; then
wget http://mattmahoney.net/dc/text8.zip
else
curl -O http://mattmahoney.net/dc/text8.zip
fi
unzip text8.zip
rm text8.zip
fi
CORPUS=text8
VOCAB_FILE=vocab.txt
COOCCURRENCE_FILE=cooccurrence.bin
COOCCURRENCE_SHUF_FILE=cooccurrence.shuf.bin
BUILDDIR=build
SAVE_FILE=vectors
VERBOSE=2
MEMORY=4.0
VOCAB_MIN_COUNT=5
VECTOR_SIZE=50
MAX_ITER=15
WINDOW_SIZE=15
BINARY=2
NUM_THREADS=8
X_MAX=10
$BUILDDIR/vocab_count -min-count $VOCAB_MIN_COUNT -verbose $VERBOSE < $CORPUS > $VOCAB_FILE
if [[ $? -eq 0 ]]
then
$BUILDDIR/cooccur -memory $MEMORY -vocab-file $VOCAB_FILE -verbose $VERBOSE -window-size $WINDOW_SIZE < $CORPUS > $COOCCURRENCE_FILE
if [[ $? -eq 0 ]]
then
$BUILDDIR/shuffle -memory $MEMORY -verbose $VERBOSE < $COOCCURRENCE_FILE > $COOCCURRENCE_SHUF_FILE
if [[ $? -eq 0 ]]
then
$BUILDDIR/glove -save-file $SAVE_FILE -threads $NUM_THREADS -input-file $COOCCURRENCE_SHUF_FILE -x-max $X_MAX -iter $MAX_ITER -vector-size $VECTOR_SIZE -binary $BINARY -vocab-file $VOCAB_FILE -verbose $VERBOSE
if [[ $? -eq 0 ]]
then
**if [ "" = 'matlab' ]; then
matlab -nodisplay -nodesktop -nojvm -nosplash < ./eval/matlab/read_and_evaluate.m 1>&2
elif [ "" = 'octave' ]; then
octave < ./eval/octave/read_and_evaluate_octave.m 1>&2
else
python eval/python/evaluate.py
fi**
fi
fi
fi
fi
简而言之:
Glove 1.2 的新版本解决了您的问题。就 运行 吧。
matlab、octave 或 python,其中之一足以 运行ning 脚本。如果您有其中之一,demo.sh 会处理它。
我已经尝试 运行 我的 Ubuntu 机器上的手套。没关系,直到它给了我以下抱怨 matlab 的错误:
./demo.sh: line 37: matlab: command not found
任何人都可以帮助我如何在我的机器上为 运行 Glove 设置 matlab 吗?
解法一:
matlab命令部分只是glove tool的内在测试部分。
您不需要 运行 demo.sh 的那部分来生成词向量。
解法-2:
此外,随着 GloVe 的新版本 版本 1.2,有 python 代码可以做到这一点。 Matlab 不是必需的,python 会处理它。
demo.sh 有一个 if elif 代码部分,它检查机器上是否存在 matlab 运行ning。如果存在,它 运行s matlab,如果不存在,则检查八度。如果存在八度,则为 运行s 八度。如果八度音阶不存在,它 运行s 与 python。 demo.sh有如下代码,matlab部分是最后一部分:
#!/bin/bash
# Makes programs, downloads sample data, trains a GloVe model, and then evaluates it.
# One optional argument can specify the language used for eval script: matlab, octave or [default] python
make
if [ ! -e text8 ]; then
if hash wget 2>/dev/null; then
wget http://mattmahoney.net/dc/text8.zip
else
curl -O http://mattmahoney.net/dc/text8.zip
fi
unzip text8.zip
rm text8.zip
fi
CORPUS=text8
VOCAB_FILE=vocab.txt
COOCCURRENCE_FILE=cooccurrence.bin
COOCCURRENCE_SHUF_FILE=cooccurrence.shuf.bin
BUILDDIR=build
SAVE_FILE=vectors
VERBOSE=2
MEMORY=4.0
VOCAB_MIN_COUNT=5
VECTOR_SIZE=50
MAX_ITER=15
WINDOW_SIZE=15
BINARY=2
NUM_THREADS=8
X_MAX=10
$BUILDDIR/vocab_count -min-count $VOCAB_MIN_COUNT -verbose $VERBOSE < $CORPUS > $VOCAB_FILE
if [[ $? -eq 0 ]]
then
$BUILDDIR/cooccur -memory $MEMORY -vocab-file $VOCAB_FILE -verbose $VERBOSE -window-size $WINDOW_SIZE < $CORPUS > $COOCCURRENCE_FILE
if [[ $? -eq 0 ]]
then
$BUILDDIR/shuffle -memory $MEMORY -verbose $VERBOSE < $COOCCURRENCE_FILE > $COOCCURRENCE_SHUF_FILE
if [[ $? -eq 0 ]]
then
$BUILDDIR/glove -save-file $SAVE_FILE -threads $NUM_THREADS -input-file $COOCCURRENCE_SHUF_FILE -x-max $X_MAX -iter $MAX_ITER -vector-size $VECTOR_SIZE -binary $BINARY -vocab-file $VOCAB_FILE -verbose $VERBOSE
if [[ $? -eq 0 ]]
then
**if [ "" = 'matlab' ]; then
matlab -nodisplay -nodesktop -nojvm -nosplash < ./eval/matlab/read_and_evaluate.m 1>&2
elif [ "" = 'octave' ]; then
octave < ./eval/octave/read_and_evaluate_octave.m 1>&2
else
python eval/python/evaluate.py
fi**
fi
fi
fi
fi
简而言之: Glove 1.2 的新版本解决了您的问题。就 运行 吧。 matlab、octave 或 python,其中之一足以 运行ning 脚本。如果您有其中之一,demo.sh 会处理它。