ã¨ããçºè¡¨ã Tokyo.SciPy #2 ã§ããã¦ããã£ãã®ã ããçºè¡¨ï¼è³æä½æã®æéã®é¢ä¿ã§ãå®éã«æ°å¼ã解éããä¾ã2ã¤ããå
¥ããããªãã£ãã®ãæ®å¿µãªã¨ããã
ä»ã社å
PRML èªæ¸ä¼ã§ 13ç« ã®é ããã«ã³ãããã£ã¤ãã¦ãã¦ããã® Baum-Welch ã®æ´æ°å¼ãã¡ããã©ããé¡æã«ãªã£ã¦ãããã¨ã«æ°ä»ããã®ã§ãããã§åãä¸ãã¦ã¿ãã
- ã (PRML å¼ 13.36)
çµæ§è¤éãªå°è±¡ã®ããæ°å¼ã ããããã¤ãè³æã®æµãã«å¾ãã°ç°¡åã«å®è£ ã§ãã¦ãã¾ããã¨ãè¦ã¦ãããã
- æ°å¼ãèªã¿è§£ã
- æ°å¼ãæ¸ãæãã
- numpy ã«ãéèªè¨³ããã
ã¨ããããã§ã¾ããèªã¿è§£ããã ãããããä¸çªéè¦ãªã¹ãããã
ç¹ã«ä»åã®å¼ã®å ´å㯠, , ã®æ£ä½ãã¡ããã¨è¦æ¥µãã¦ãããªãã¨ãããªãã
ãæ£ä½ãã¨ã¯ãã¤ã¾ãã¹ã«ã©ã¼ããã¯ãã«ãè¡åãããã¯ãã«ãè¡åãªããã®æ¬¡æ°ã¯ä½ããããã¦ãã®è¦ç´ ã¯ã©ã®ããã«æ¸ããããã¨ããç¹ã ã
ã¾ã ã¯æ¬¡ã®ããã«å®ç¾©ããã¦ããã
- ã (PRML å¼ 13.34)
x_n ãã¡ã¯è¦³æ¸¬å¤ã§åºå®ããã¦ãã¦ãz_n 㯠1-of-K 表ç¾ã§ K éãã®å¤ãåãå¾ãã
ã¨ãããã㧠㯠K 次ã®ãã¯ãã«ã§ãããã¨ãããã
z_n ã¯æ¬æ¥ 1-of-K 表ç¾ã ããz_n ã® k çªç®ã ãã 1 ã§ãããã¨ã "z_n=k" ã¨æ¸ããã¨ã«ããã¨ã
ã¨ãªãã
alpha(z_n) ãªãã¦æ¸ãæ¹ã§ã¯ãã¨ã¦ããã¯ãã«ã«ã¯è¦ããªããå®ã¯ãã¯ãã«ã ãã¨è¨ã£ã¦ãç´ããããã ããªã®ã§ãä»å¾ ã¨æ¸ããã¨ã«ããããã® k çªç®ã®è¦ç´ 㯠ã¨æ¸ãã¦ãããããããã
次㫠ã®å®ç¾©ã¯
- ã (PRML å¼ 13.7)
ã¨æ¸ããã¦ããã
ãã㯠1-of-K 表ç¾ã®ããã§å¤é
åå¸ãããããã表ç¾ããã¦ãã¾ã£ã¦ããã ãã§ãä¸ã®è¨æ³ã許ãã°ã以ä¸ã®ããã«æ¸ããã
ã¤ã¾ã 㯠KÃK è¡åã§ãã£ããã¨ããããã
æå¾ã« ã ããä»åã¯åºååå¸ã«å¤é åå¸ã使ããã¨ã«ããã¨ããã®å®ç¾©ã¯ (PRML å¼ 13.22) ã«æ¸ããã¦ããããããã¯ä¸ã® p(z_n|z_{n-1}) ã¨å ¨ãåãå½¢ãªã®ã§ãåæ§ã«æ¬¡ã®å½¢ã«ãªããã¨ããããã
ãããã 㯠DÃK è¡åã ã£ãããã ã
ã©ãã ãããããã¾ã§èªã¿è§£ããã ãã§ããæåã®å¼ããã§ã«ã ãã¶ç°¡åã«è¦ãã¦ããã®ã§ã¯ãªãã ãããã
èªã¿è§£ãã¹ããããçµãã£ãã®ã§ãæ°å¼ãæ¸ãæãããã
è³æãããæ¸ãæãæ¹éã«ã¤ãã¦æ¸ãããã¼ã¸ãå¼ç¨ãã¦ã¿ãã
ãã¯ãã«ã»è¡åã®ç©ã®æ°å¼ã¯ããã®ããã«è¦ç´ ã®æ°å¼ã«æ¸ãæãã¦ãä¸ã®3種é¡ã®å½¢ã«å½ã¦ã¯ãã¦ããããããã
å
ã®æ°å¼ãè¦ç´ ã®å½¢ã«æ¸ãæããã«ã¯ãã¾ã左辺ã K 次ã®ãã¯ãã«ã ã£ããã¨ãæãåºãããã® k çªç®ã®è¦ç´ ãæ±ããå¼ãç«ã¦ããã¨ãèããããã®ã¨ã ã ã£ãã®ã§ãz_n=k ãå³è¾ºã«å½ã¦ã¯ããã
次㫠z_{n-1} ã§åãåã£ã¦ããã¨ãããããããã㯠1 ãã K ã¾ã§åãã¨ãããã¨ãªã®ã§ãz_{n-1}=j ã¨ããã¦ãj ã 1 ãã K ã¾ã§åããã¨ã«ãããããã¡ãã z_{n-1}=j ãå³è¾ºã«å½ã¦ã¯ãã¦ãããã
ããã¨æ¬¡ã®å¼ãå¾ãããã
x_n ã¯è¦³æ¸¬å¤ãªã®ã§ãä»ãã®ä¸ããããå¤ã i ã¨æ¸ããã¨ã«ããã°ãp(x|z) ãã¡ã®å®ç¾©ããããã®å¼ã¯ããã«æ¬¡ã®ããã«ãªãã
ãããã©ãã©ãç°¡åã«ãªã£ã¦ãããããã§ä¸ã®æ¸ãæãæ¹éãæãã ããã
ä»ãæ°å¼ã®ä¸ã§Î£ãããã¨ããããããç®ç«ã£ã¦ããã®ã§ã2çªç®ã®è¡åç©ã®å½¢ã«å½ã¦ã¯ããããªãã
è¡åç©ã«ããã«ã¯ãåãåã£ã¦ããã¤ã³ããã¯ã¹ã® j ãçãä¸ã§ãã¢ã«ãªãããã«ããã°ãããã ãã©ããã¯ãã«ã¯ KÃ1 次å
ã®è¡åã¨ã¿ãªããã ã£ããã¨ãå¿ããã«(è³æã®ä»ã®ãã¼ã¸ã«ã¯ã¡ããã¨æ¸ãã¦ããã)ã
ã¨ããããã§ã転置ããã¾ã使ã£ã¦æ·»ãåã®é çªãå
¥ãæ¿ãããã¨ã§
ã¨ãªãã
ãã¾ãã«è¡åç©ã表ãã¦ããã®ã§ã ã¨ããã°ã b 㯠K 次ã®ãã¯ãã«ã§ã ã§ãããã¨ããããã
ä¸ã®å¼ã®è©²å½é¨åã b_k ã«ç½®ãæããã¨ãããã«ç°¡åã«ãªãã
ãããä¸ã®æ¹éã¨è¦æ¯ã¹ãã¨ãå
¨ã¦ã®é
ã k ã¨ããä¸ã¤ã®ã¤ã³ããã¯ã¹ã«ããä¾åãã¦ããªã(i 㨠n ã¯åºå®)ã®ã§ãä»åº¦ã¯è¦ç´ ç©ã®å½¢ããã¦ãããã¨ããããã
è¦ç´ ç©ã¯æ°å¼ã®è¨å·ããªãã®ã§ãã¨ãããã * ã¨æ¸ããã¨ã«ããã¨ãæåã®æ°å¼ã¯å®ã¯æ¬¡ã®ããã«æ¸ãæãããããã¨ãããã£ãã
ãããå®è£ ããã®ã¯ããããããããalpha, A, mu ãããããé©å½ãªãã¯ãã«ãè¡åã§ããã°ã
alpha[n] = mu[i,:] * numpy.dot(A.T, alpha[n-1])
ã§ããã¾ãã
èªã¿è§£ãã¨æ¸ãæ¿ãã¯ç¹ã« numpy ã«éã£ã話ã§ã¯ãªããããã®ãéèªè¨³ãã¯ã»ã¨ãã©ã®è¡åã©ã¤ãã©ãªã§ã§ããã¬ãã«ã
ãã¡ãã R ã§ãç°¡åã«å®è£
ã§ããã
βã®æ´æ°å¼ (PRML å¼ 13.38) ãåæ§ã«æ¸ãæããã°ããã¯ã誰ã§ãå®è£ ã§ããã®ã§ãç·´ç¿åé¡ã§ãã£ã¦ã¿ãã¨ãããããããã