GithubHelp home page GithubHelp logo

lapis-zero09 / compare_word_embedding Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 0.0 28 KB

意味表現学習

Home Page: https://www.lapis-zero09.xyz/29th.html

Python 45.02% Jupyter Notebook 54.98%
glove glove-python embeddings ppmi word2vec svd cbow sg skip-gram bag-of-words

compare_word_embedding's Introduction

compare_word_embedding

Pre-processing

$ mkdir tmp
$ mkdir model
$ python preprocess.py

Train

$ python w2v.py
$ python glove_train.py
$ python ppmi.py
$ python svd.py

Predict

$ python predict.py

methods

  • Distributional semantic representation

    • Positive Pointwise Mutual Information(PPMI)

    • Singular Value Decomposition(SVD)

  • Distributed semantic representation

    • Word2Vec

      • Continuous Bag Of Words(CBOW)
      • Skip-gram(SG)
    • GloVe

Dependencies

Python-version

  • Python 3.6.0 :: Anaconda 4.3.1 (x86_64)

MeCab dictionary

  • mecab-ipadic-neologd

Packages

  • gensim==0.13.4.1
  • glove-python==0.1.0
  • mecab-python3==0.7

how to install glove-python on OS X El Capitan

glove-pythonはデフォルトでは動かない.

Macの標準コンパイラがgccではなくclangだからである.

glove-pythonには環境を調査し,それに応じたコンパイラを指定する機能があるがそれが 標準では動作していない.

Githubからcloneする

$ git clone https://github.com/maciejkula/glove-python.git

setup.pyを編集

define_extensions関数のはじめにset_gcc関数を呼び出すようにする


def define_extensions(cythonize=False):
    set_gcc()
    compile_args = ['-fopenmp',
                    '-ffast-math']

以下を実行するとインストールできる

$ sudo python setup.py install

できない場合はgcc周りの環境が整っていないので,gccの4.9以上をインストール

$ brew install gcc

References

compare_word_embedding's People

Contributors

lapis-zero09 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

compare_word_embedding's Issues

unhashable type: 'matrix'

The below code in model_test.py generates the following error

most_similar_dist(ppmi, positive=['reproduction'], negative=[], topn=3)


TypeError Traceback (most recent call last)
in
----> 1 most_similar_dist(ppmi, positive=['reproduction'], negative=[], topn=3)

/mnt/50c93f6b-d279-4699-abe2-5ac73a36bedf/Vinay/similar_word.py in most_similar_dist(model, positive, negative, topn)
43 best = numpy.argsort(dists)[::-1][:topn + len(all_words)]
44
---> 45 result = [(model.id2word[sim], float(dists[sim])) for sim in best if sim not in all_words]
46
47 return result[:topn]

/mnt/50c93f6b-d279-4699-abe2-5ac73a36bedf/Vinay/similar_word.py in (.0)
43 best = numpy.argsort(dists)[::-1][:topn + len(all_words)]
44
---> 45 result = [(model.id2word[sim], float(dists[sim])) for sim in best if sim not in all_words]
46
47 return result[:topn]

TypeError: unhashable type: 'matrix'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.