ä¹
ãã¶ãã®è¨äºæ´æ°ã§ãã
ä»åã¯ããã¦ããæ¸ãã¦ã¿ããã£ãword2vecã«ã¤ãã¦ã
word2vecã¯ã¨ã¦ãé¢ç½ãèãæ¹ãªã®ã§ãããå人çã«ã¯ä»çµã¿ãã¡ãã£ã¨æãã¥ãããç解ããã®ã«çµæ§æéããããã¾ããã
ããã§ä»åã¯ãéå»ã®èªåãæããããã«ãword2vecãã§ããã ãç°¡æ½ã«ãããã¦ç´è¦³çã«ç解ã§ããããã«è§£èª¬ãã¦ããã¾ãã
ãªããword2vecã«ã¤ãã¦ã¯ä»¥ä¸æ¸ç±ã§ããã¾ã¨ã¾ã£ã¦ããã®ã§ããããããã°æ¯éï¼
Pythonã¨å®ãã¼ã¿ã§éãã§å¦ã¶ ãã¼ã¿åæè¬åº§
- ä½è : æ¢ æ´¥éä¸,ä¸éè²´åº
- åºç社/ã¡ã¼ã«ã¼: ã·ã¼ã¢ã³ãã¢ã¼ã«ç 究æ
- çºå£²æ¥: 2019/08/10
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- ãã®ååãå«ãããã°ãè¦ã
â»è¿½è¨â»
ã¹ããã®AMPã ã¨ãè¡åãæ°å¼ããã¾ã表示ãããªãå¯è½æ§ãããã¾ãã®ã§ããã¡ãã®ãªã³ã¯ãPCããè³¼èªé ãã¾ãã¨å¹¸ãã§ãã
word2vecã使ãã¨ä½ãã§ããã®ï¼
ããããword2vecã使ãã¨ä½ãå¬ããã®ãï¼ã«ã¤ãã¦ãã¾ãã¯èª¬æãã¾ããword2vecã¯ã大éã®ããã¹ããã¼ã¿ã解æããååèªã®æå³ããã¯ãã«è¡¨ç¾åããææ³ã§ããåèªããã¯ãã«åãããã¨ã§ã
- åèªå士ã®æå³ã®è¿ããè¨ç®
- åèªå士ã®æå³ã足ãããå¼ããã
ã¨ãããã¨ãå¯è½ã«ãªãã¾ãã
ä¾ãã°ãword2vecã«ãããæ¾æ¬äººå¿ãããæµç°é åããããã±ãããããã³ããã¨ããè¨èã以ä¸ã®ããã«ãã¯ãã«åã§ããããã¾ãã
- æ¾æ¬äººå¿ï¼
- æµç°é åï¼
- ãã±ï¼
- ããã³ãï¼
ãã®ãã¯ãã«è¡¨ç¾ããã
- ãæ¾æ¬äººå¿ãããæµç°é åãã®è·é¢ãè¨ç®ããã¨ãçµæ§è¿ãã¨ããã«ããããã ããªã®ã§äºã¤ã®æå³ã¯è¿ãã®ã§ã¯ï¼
- ãæ¾æ¬äººå¿ã - ããã±ã + ãããã³ãã â ãæµç°é åã ã«ãªãã
ã¨ãã£ãèå¯ã»è¨ç®ãã§ãã¾ãã
åèªãã¯ãã«ãä½ãããã«å¿ è¦ãªãã§ã¤ã¯ã¿ã¹ã¯
åèªãã¯ãã«ãããã¨è²ã 楽ããåæãã§ãããã¨ãåãã£ãã¨ããã§ãå®éã®word2vecã®ä»çµã¿ã説æãã¦ããã¾ããããword2vecã«ã¯å¤§ããåãã¦- CBOW
- Skip-Gram Model
ã¨ãã2ã¤ã®ææ³ãããã¾ãã
Skip-Gram Modelã®æ¹ãåãããããã®ã§ãä»åã¯ãã¡ãã使ã£ãword2vecã解説ãã¦ããã¾ãã
åèªãã¯ãã«ãç´æ¥æ±ãããã¨ã¯å¤§å¤ãªã®ã§ãword2vecã§ã¯ãããå½ã®ã¿ã¹ã¯ã解ããã¨ãèãããã®éç¨ã§éæ¥çã«è¨ç®ãã¦ããã¾ãã
ãã®è¾ºããword2vecã®æãã¥ãããã¤ã³ãããªã¨æãã¾ãã
ãéæ¥çã«æ±ãããã£ã¦ãªã«ï¼ãã¨æãããããããã¾ãããããã®çåãå¿ã®çé
ã«ç½®ããã¾ã¾ãæå¾ã¾ã§ãä»ãåãããã ããã°ã
æå³ãè¿ãåèªã¨å¨è¾ºèªã®é¢ä¿æ§
æå³ãè¿ãï¼âåèªãã¯ãã«ã®è·é¢ãè¿ãï¼è¨èã¯å¨è¾ºèªãä¼¼ã¦ããã¯ãã§ãããç§ã¯æ±æ¥ç°åé½å¸ç·ã®ä¸è»è¶å±é§
ä»è¿ã«ä½ãã§ãã¾ããã
ãç¥å¥å·ã®æºã®å£ã«ã¯ãæ±æ¥ç°åé½å¸ç·ã¨JRåæ¦ç·ãèµ°ã£ã¦ãã¾ããã
ãã®ãããªæããã£ãã¨ãã¾ãããã
- ä¸è»è¶å±
- æºã®å£
ã¨ãã2ã¤ã®è¨èã¯ã©ã¡ãããæ±æ¥ç°åé½å¸ç·ãã¨ããåèªããè¿ãã¨ããã«é
ç½®ããã¦ãã¾ãã
ã¨ãããã¨ã¯ããã®äºã¤ã®åèªã¯æ¯è¼çè¿ãå±æ§ãªã®ã§ã¯ãªããï¼ã¨äºæ³ã§ãã¾ãã
ä»ã«ãä¾ãã°ããPythonãããRãã¨ããåèªã®è¿ãã«ã¯ããã¼ã¿ãã¨ããåèªãããç¾ãã¾ããéã«è¨ãã°ãããã¼ã¿ãã¨ããåèªãå¨è¾ºã«ããç¾ãããPythonãã¨ãRãã¯ä¼¼ã¦ããæå³ãªã®ã§ã¯ï¼ã¨èãããããã§ãããã
ãååèªã¯ãã®å¨è¾ºèªã¨ä½ããã®é¢ä¿æ§ããããã¨ããèããå ã«ããããåèªãä¸ããæã«ãã®å¨è¾ºèªãäºæ¸¬ããããããªã¿ã¹ã¯ã解ãããã§ãããã
ãããåè¿°ããããå½ã®ã¿ã¹ã¯ã®æ£ä½ã§ãã
ã¨ãããã¨ã§ã次ç¯ã§ãã®åé¡ãå®éã«è§£ãããã«ãã¥ã¼ã©ã«ããããæ§æãã¦ã¿ã¾ãããã
å ¥å層ã»é ã層ã»åºå層ã®ã¿ã®ãã¥ã¼ã©ã«ãããã¯ã¼ã¯
word2vecã®Skip-Gram Modelã§ã¯ãå ¥åãããåèªãå ã«å¨è¾ºèªãåºåãããå ¥å層ã»é ã層ã»åºå層ã®ã¿ã®ã·ã³ãã«ãªãã¥ã¼ã©ã«ããããèãã¾ããä¸å³ã®ãããªã¤ã¡ã¼ã¸ã§ãã
ã¨ã¦ãã·ã³ãã«ãªæ§é ã§ããã
ããåèªãå
¥åãã¼ã¿ã«ãããã¦ãã®å¨è¾ºèªãæ師ãã¼ã¿ã«ãã¦ãéã¿ãå¦ç¿ãã¦ããã¾ãã
ããã§ããã©ãã¾ã§ãå¨è¾ºèªã¨ãããï¼ãã¨ãããã¨ãéè¦ã§ããå¨è¾º5åèªï¼åå¾åããã¦10åèªï¼ã¨ããã®ãä¸è¬çãªããã§ãããé©å®èª¿æ´ãã¤ã¤åæãé²ãã¾ãããã
ä¾ãã°ãï¼æ¥æ¬èªãããè±èªã®æ¹ãåãããããã®ã§è±èªã§èª¬æãã¾ããï¼
ãI usually go to the company near Sangenjaya station on the Denentoshi line.ã
ãã®æãããå
¥åèªã¨å¨è¾ºèªã®ã»ãããåãåºãã¦ã¿ã¾ãããã
- I ãå ¥åèªã®å ´åï¼(I, usually), (I, go), (I, to), (I, the), (I, company)ã®5å
- usually ãå ¥åèªã®å ´åï¼(usually, I), (usually, go), (usually, to), (usually, the), (usually, company), (usually, near)ã®6å
- go ãå ¥åèªã®å ´åï¼(go, I), (go, usually), (go, to), (go, the), (go, company), (go, neaar), (go, Sangenjaya )ã®7å
ã»ã»ã»
- company ãå ¥åèªã®å ´åï¼(company , I), (company , usually), (company , go), (company , to), (company , the), (company , near), (company ,Sangenjaya ), (company , station ), (company , on), (company , the)ã®10å
ã»ã»ã»
ã¨ãã風ã«ããããã»ããã§ãã¼ã¿ãåãåºããã¨ãã§ãã¾ãã
Iãå
¥åãããã¨ãusuallyãgoã¨ããåèªãäºæ¸¬çµæã¨ãã¦åºåãããããã«ãã¥ã¼ã©ã«ããããå¦ç¿ãã¦ããã¤ã¡ã¼ã¸ã§ãã
1æã ãã§ãã®ããã«å¤ãã®å
¥åèªã¨å¨è¾ºèªã®ã»ãããåå¾ã§ãããã¨ãèããã¨ã大éã®ããã¹ããã¼ã¿ãèªã¿è¾¼ãã¨ã¨ãã§ããªãéã®ãã¼ã¿ãå¾ããããã§ããã
å ¥åãã¼ã¿ã¨æ師ãã¼ã¿ã¨éã¿è¡å
ç°¡åã®ããããI usually go to the company near Sangenjaya station on the Denentoshi line.ãã®ã¿ããå¦ç¿ããããã¹ããç¡ãã¨ãã¾ããããåèªæ°ãæ°ããã¨12ã§ããããã¡ããå®éã«å¦ç¿ãããéã¯ã大éã®ããã¹ããèªã¿è¾¼ã¿ãä½ä¸ï½ä½ç¾ä¸ã¨ããåä½ã®åèªãç¨ãã¾ãã
I ã usually, go ã¨ããåèªããã®ã¾ã¾æååã®ç¶æ ã§è¨ç®ãããã¨ã¯ã§ããªãã®ã§ãä½ããã®æ¹æ³ã§æ°å¤åããå¿ è¦ãããã¾ãã
å ¨é¨ã§12åèªãªã®ã§ã
- Iï¼
- usuallyï¼
- goï¼
- toï¼
â¦
- lineï¼
ã¨ãã風ã«å¤æããã¨è¯ãã§ãããããã®ãããªãä¸ã¤ã®è¦ç´ ã ãã1ãã§æ®ãã¯ã0ãã®ãã¯ãã«ããone-hotãã¯ãã«ã¨è¨ãã¾ãã
ãªã®ã§å
¥åèªã¨å¨è¾ºèªã®ã»ãããã(I, usually)ã ã¨ããã¨ãä¸å³ã®ãããªãã¯ãã«ããã¥ã¼ã©ã«ãããã«å¦ç¿ãããã¨ãããã¨ã«ãªãã¾ãã
åæ§ã«(I, go)ã ã¨ä»¥ä¸ã®ããã«ãªãã¾ãã
å ¥å層ã®æ¬¡å ãä»å12次å ãªã®ã§ãåããåºå層ã12次å ã§ãã
å®éã«word2vecãç¨ããéã¯ãå
¥å層ãæ°ä¸æ¬¡å
ã®ãã¯ãã«ãå
¥å層ããé ã層ã¸ã®éã¿è¡åããæ°ä¸ à æ°ç¾ã®æ¬¡å
ã«è¨å®ãããã¨ãå¤ãããã§ãã
ããã§ã¯ç°¡åã®ãããå
¥å層ããé ã層ã¸ã®éã¿è¡åã§ããã ã¨ãã¾ããããããã¨ãé ã層ããåºå層ã¸ã®éã¿è¡å㯠ã¨ãªãã¾ãã
ã¾ã¨ããã¨ã
- å ¥åãã¯ãã«ï¼ ï¼ã«ãå ¥å層ããé ã層ã¸ã®éã¿è¡åï¼ ï¼ããããå¾ããã ã®ãã¼ã¿ãé ã層ã«å ¥ããã
- é ã層ã®å¤ã«ãé ã層ããåºå層ã¸ã®éã¿è¡åï¼ ï¼ããããå¾ããã ã®ãã¼ã¿ãåºå層ã«å ¥ããã
ã¨ããæµãã§ããã¾ããããã¯åé¡åé¡ãªã®ã§åºå層ã«ã¯ã½ããããã¯ã¹é¢æ°ããã¾ãã¦ã確çåãã¦ãããå¿
è¦ãããã¾ãã
åé¡åé¡ã解ãããã®ãã¨ã¦ãã·ã³ãã«ãªãã¥ã¼ã©ã«ãããã§ããã
ãã§ã¤ã¯ã¿ã¹ã¯ã®çµæã¨åèªãã¯ãã«ã®é¢ä¿æ§
ãã¦ãããã¹ãããå ¥åèªã¨å¨è¾ºèªã®ã»ãããä½ãããã®ãã¼ã¿ãå ã«ãå ¥åãããåèªããå¨è¾ºèªãäºæ¸¬ããå¦ç¿ããè¡ããã¨ã§ã- å ¥å層ããé ã層ã¸ã®éã¿è¡åï¼
- é ã層ããåºå層ã¸ã®éã¿è¡åï¼
ãè¨ç®ããã¾ããã
ä¾ãã°ã以ä¸ã®ãããªå
¥å層ããé ã層ã¸ã®éã¿è¡åããå¦ç¿ã®çµæä½ããã¨ãã¾ãã
åè¿°ããã¨ãããå ¥åã¯one-hotãã¯ãã«ã§ãã
ä¾ãã°ãusuallyãï¼ç¬¬2æåã®ã¿1ã§æ®ãã¯0ï¼ã¨ããåèªãå ¥åãããéãé ã層ã®å¤ã¯
åæ§ã«ãcompanyãï¼ç¬¬6æåã®ã¿1ã§æ®ãã¯0ï¼ã¨ããåèªãå ¥åãããéãé ã層ã®å¤ã¯
ãããã®å¤ãé ã層ã«å ¥ããã¾ããããããããã¦ããããã¨ã§åºå層ã®å¤ã決ã¾ãã¾ãã
ãã®è¾ºããä¸çªå¤§åãªã®ã§ãããä¸åº¦ã¾ã¨ãã¾ãã
ãusuallyãï¼ç¬¬2æåã®ã¿1ã§æ®ãã¯0ï¼ãå
¥å層ã«å
¥ã£ãã¨ããã¨ãéã¿è¡åã®ç¬¬2è¡ããã®ã¾ã¾é ã層ã«å
¥ãã
ããã¦ãcompanyãï¼ç¬¬6æåã®ã¿1ã§æ®ãã¯0ï¼ãå
¥å層ã«å
¥ã£ãã¨ããã¨ãéã¿è¡åã®ç¬¬6è¡ããã®ã¾ã¾é ã層ã«å
¥ãã
ãããã¦è¨ç®ãããé ã層ã®å¤ãå
ã«ãåºå層ãè¨ç®ãããâ¦â¦
ã¨ãããã¨ã¯ã
- ãusuallyãã¨ããåèªãæã¤ç¹æ§ã¯ãéã¿è¡åã®ç¬¬2è¡ç®ã®å¤ã§ãã
- ãcompanyãã¨ããåèªãæã¤ç¹æ§ã¯ãéã¿è¡åã®ç¬¬6è¡ç®ã®å¤ã§ãã
ã¨çµè«ã¥ãã¦ãå
¨ãå¼·å¼ãããªãã§ãããï¼
ãªããªããçµå±ã¯ååèªã¨å¯¾å¿ããè¡ã®éã¿ãããã®å¾ã®è¨ç®ã«ä½¿ããã¦ããªãã®ã§ã
åæ§ã«ã
- ãIãã¨ããåèªãæã¤ç¹æ§ã¯ãéã¿è¡åã®ç¬¬1è¡ç®ã®å¤ã§ãã
- ãusuallyãã¨ããåèªãæã¤ç¹æ§ã¯ãéã¿è¡åã®ç¬¬2è¡ç®ã®å¤ã§ãã
- ãgoãã¨ããåèªãæã¤ç¹æ§ã¯ãéã¿è¡åã®ç¬¬3è¡ç®ã®å¤ã§ãã
â¦
- ãlineãã¨ããåèªãæã¤ç¹æ§ã¯ãéã¿è¡åã®ç¬¬12è¡ç®ã®å¤ã§ãã
ã¨ãããã¨ã§ãå ¥å層ããé ã層ã¸ã®éã¿è¡åãå ã«åèªã®ç¹æ§ããã¯ãã«åãããã¨ãã§ãã¾ããï¼
ããã¾ã§ãå ¥åèªããå¨è¾ºèªããäºæ¸¬ããã¨ããå½ã¿ã¹ã¯ããã¥ã¼ã©ã«ãããã§è§£ãã¦ãã¾ããããç®çã¯ãã®å ¥å層ããé ã層ã¸ã®éã¿è¡åã ã£ããã§ããï¼
éã¿è¡åã®åè¡ã®ãã¯ãã«ãããã®ã¾ã¾åèªã®ç¹å¾´ã表ããã¯ãã«ã«ãªãããã§ãã
å ¨ä½ã®æµãããããã
ã¤ã¾ãã- åããããªæå³ã®åèªããã¯ãåããããªå¨è¾ºèªãäºæ¸¬ãããã¯ã
- ããåèªã®å¨ãã«åºç¾ããåèªãäºæ¸¬ããå¦ç¿ãããã¥ã¼ã©ã«ãããã¯ã¼ã¯ã§è¡ã
- å¦ç¿ã®çµæãå ¥å層ããé ã層ã¸ã®éã¿ãè¨ç®ããã
- å ¥åãont-hotãã¯ãã«ãªã®ã§ãå ¥å層ããé ã層ã¸ã®éã¿è¡åã®åè¡ãããã®ã¾ã¾åèªãã¯ãã«ã¨è¡¨ç¾ãã¦ããã ãã
ã¨ããæµãã§ãã
é·ã説æã§ããããæå¾ã¾ã§èªãã§ããã ããæ¹ã
ãããã¨ããããã¾ãã
ããã¦ãç²ãæ§ã§ããï¼
ã¾ã¨ã
ä»åã¯word2vecã«ã¤ãã¦ä»çµã¿ãã¾ã¨ãã¾ããããã®ãããåãããããæ¸ããã®ã§ã¯ãªããã¨èªç»èªè³ãã¦ãã¾ãç¬ã
ãã£ããçè«é¢ãå¦ãã ã®ã§ã次åããã¯Pythonã¨Rã使ã£ã¦å®éã«åæãã¦ã¿ã¾ãããã
ãã¡ããé¢ç½ãåæãã§ãããã§ãã
ã楽ãã¿ã«ï¼ï¼
追è¨
äºå®éããPythonã¨Rã§å®è·µè¨äºãæ¸ãã¾ãããæ¯éèªãã§ã¿ã¦ãã ãããPythonå®è·µè¨äº
www.randpy.tokyo
Rå®è·µè¨äº
www.randpy.tokyo