Magia Book (II)

memorandum

相互情報量(Mutual information)= 伝達情報量(Transinformation)

wikipediaより形式的には,2つの離散確率変数XとYの相互情報量
{
I(X;Y) = \sum_{y \in Y}  \sum_{x \in X} p(x, y) \log \frac{p(x,y)}{p(x)p(y)}
 p(x, y)
}
によって定義される

2つの確率変数の相互依存の尺度を表す量.

最も典型的な相互情報量の物理単位はビットで,2 を底とする対数が使われることが多い

XとYが独立のとき,同時確率は0のため,I(X;Y)=0となる

XとY が最も依存していないときに,相互情報量は最小となる

Yの分布がXの分布と同じである場合に,I(X;Y)は最大値となる

XとYが最も依存しているときに,相互情報量は最大となる

githubのssh keyの変更

ここにかいてあることを実行すればだいたいいけるんですが,少し補足

まず好きなディレクトリ(~/path)で以下を実行

ssh-keygen -t rsa -C “youraddress@example.com” -f github_id_rsa

で鍵を作ります

pbcopy < github_id_rsa.pub

github_id_rsa.pubの内容をコピーして,GithubのSettings -> SSH GPG keyのSSH keyにコピー内容を貼り付けます

.sshの下にconfigファイルを作成するとき,.sshはホームディレクトリにあります

cd ~/.ssh
vim config

とかで以下のように編集します

Host github.com
 User git
 Port 22
 HostName github.com
 IdentityFile ~/path/github_id_rsa
 TCPKeepAlive yes
 PreferredAuthentications publickey
 IdentitiesOnly yes

IdentityFileの項目はgithub_id_rsaがある場所を指定しましょう

あとは

ssh -T git@github.com

でHi!と元気な感じで言われたらOKです

Numpyの使える関数や注意点

numpy

import numpy as np

  • np.argwhereの入力引数として左辺に代入されるarrayはndarrayでなければならない (そうでなければ頓珍漢な結果が出る)

  • numpyでndarrayのすべての要素を表示させる... np.set_printoptions(threshold='nan')

  • np.rot90: マトリクスを反時計回りにk回回転する.バージョンによってinput argsが違うので注意.

  • boolが格納された配列(マスクmask)のTrue, Falseを反転させたい場合は,~mask. -maskは警告, not maskは不可能.

  • np.array_equal: ndarrayまたはリスト同士の内容が等しいかどうかをboolで返す.

  • np.equal: ndarrayまたはリスト同士の各要素について等しいかどうかをboolの格納されたndarrayで返す.

  • np.delete: 要素ごとに削除ができる.マスクを使う方法もあるが,flattenされたarrayが返されることに注意.公式のノート参照

  • Value Error: setting an array element with a sequenceが意味するもの…中身にscalar(int, float)でないものが入っている.例えばstr型を要素にもつlistをndarrayにはできない.

  • np.sqeeze: Remove single-dimensional entries from the shape of an array.

  • np.clip: Clip (limit) the values in an array.

Referring expression(参照表現)など

referring expression(参照表現)とは何か?

  • A Joint Speaker-Listener-Reinforcer Model for Referring Expressionsより Referring expressions are natural language constructions used to identify particular objects within a scene.(あるシーン中の物体を特定するために用いられる,自然言語構造のことである)

  • referring expressionは文脈を含むためword embeddingだけで実現することは難しいと考えられる

Word embeddingとは何か?

  • Wikipediaより Word embedding is the collective name for a set of language modeling and feature learning techniques in natural language processing (NLP) where words or phrases from the vocabulary are mapped to vectors of real numbers. (単語やフレーズを数値として写像する自然言語処理(NLP)の名称である)

  • ... There are many branches and many research groups working on word embeddings. In 2013, a team at Google led by Tomas Mikolov created word2vec, a word embedding toolkit which can train vector space models faster than the previous approaches. Most new word embedding techniques rely on a neural network architecture instead of more traditional n-gram models and unsupervised learning.(近年ではword2vecなどがあり,従来的なn-gramモデルや教師なし学習が置きかわりつつある)