å¯èœã§ããã°ããããã³ã«è¡ãããªã¬ã³ãžãåããç®ããããŠç¢ºèªããããšããå§ãããŸãã æ ãæå ã«ãªãå Žå-ç§ãã¡ã¯éå±ãªæ°åŠã䜿çšããŸãïŒç§ãã¡ã¯åŠæ ¡ããã®ããŒã«ã®éãèŠããŠããŸãã ç®ã®åããçãããšããŸããã ååŸãã ã ; äžæ¹ããä»æ¹ãåŒããç®ã®äœç©ããªã¬ã³ãžã®äœç©ã§å²ããš...ç®ãçŽ16ïŒ ã§ããããšãããããŸãã ã¡ãªã¿ã«ãããã»ã©ã§ã¯ãããŸããã
1000次å ã®ç©ºéã«ãããªã¬ã³ãžã¯ã©ãã§ããïŒ
ä»åã¯ãããã³ã«è¡ããŸããåäœããŸããã 誰ããåŒãæèšããŠããããã§ã¯ãªããšæããã ãŠã£ãããã£ã¢ã¯ç§ãã¡ãå©ããŠãããã åæ§ã®èšç®ãç¹°ãè¿ããŸãããèå³æ·±ãããšã«æ¬¡ã®ããšãããããŸãã
- ãŸãã1000次å ã®ãã€ããŒãšããªã³ã¯æèãããç®ããã
- 第äºã«ãçŽ246993291800602563115535632700000000000000åã§ã
ã€ãŸããããã«å¥åŠã§ççŸããŠããããã«èŠããŠãããã€ããŒãšãã«ã·ã³ã®ã»ãŒå šäœãããã®è¡šé¢ã®ããäžã®ããããããªèãå±€ã«å«ãŸããŠããŸãã
ããããããããå§ããŸãããã
ãããã
ããã¯ã ãã¹ãã® 2çªç®ã®éšåã§ããããã®åã«ãã¡ã€ã³ã°ã©ãŒã«ïŒã¢ãã«ãã©ã¡ãŒã¿ãŒã®äºåŸç¢ºçïŒãèŠã€ããããšã«çŠç¹ãåœãŠãŠããŸããã 念ã®ãããããã«ãããŸãã ã ããäžåºŠæãåºããŠãã ãã ã¢ãã«ãã©ã¡ãŒã¿ãŒïŒããšãã°ããã¥ãŒã©ã«ãããã¯ãŒã¯ã®éã¿ïŒãããã³ -ããŒã¿ã»ããããã®ããŒã¿ïŒè¡šèšãå°ãå€æŽãã代ããã«ä»¥åã® ã ã£ã ããããåŸã§ã·ãŒã¿ãå¿ èŠã§ãïŒã
ã ããããªã¬ã³ãžã¯ããã ãã§ãã ãã®åŸéšã®å¯žæ³ã¯ããã€ããŒãšãã«ã·ã³ã®éãšåãé©ãã¹ãé床ã§æé·ããŠããŸãã ãã©ã¡ãŒã¿ãå€ãã»ã©ãååžã¯ã倧ããããªããŸãã å®éã«ã¯ããªã¬ã³ãžã§ããæ³åããªãæ¹ãè¯ãã§ããããå±±ãæ³åããŠã¿ãŸãããã å次å ã§ã ã¯ããç§ã¯ãããå°ãççŸããŠããããšãç¥ã£ãŠããŸãããããã§ã¯å±±ããããŸãïŒ
ããã¯æ¬åœã«äžæ¬¡å ã§ãã ãã³ãã³ã®èšŒèšã«ãããšããã®ãããªå次å ã®å±±ãæ³åããããšãã§ããŸããäžã®åçãèŠãŠããåïŒããšèšã£ãŠãã ãã-ãŸãã¯ããã€å¿ èŠã«ãªãã§ãããã
ç§ãã¡ã®èª²é¡ã¯ããã®å±±ã®äœç©ã調ã¹ãããšã§ãã ããããããšã§ãæã ã¯ïŒ
-ç§ãã¡ã¯ãããã©ããªåœ¢ãªã®ãããããŸããïŒãã¶ãïŒ
-ïŒä»ã®ãšããïŒæž¬å®æ¹æ³ã¯1ã€ã ãã§ã-ããå°ç¹ã«ç«ã£ãŠã足ãŸã§ã®é«ããèšç®ã§ããŸãïŒãã®å°ç¹ã«ãã確çïŒ
-å±±ã®è¡šé¢ã¯ãæé·ãããšææ°é¢æ°çã«æé·ããŸã -ãã€ããŒãšãã«ã·ã³ã®ç®èãæé·ããæ¹æ³ãšåæ§
èšç»ã¯äœã§ããïŒ
èšç»1ïŒãµã³ããªã³ã°
äžè¬çã«ã åãã€ã³ãã§çŽæ¥å±±ã枬å®ããå¿ èŠã¯ãããŸããã å±±ã®ããã€ãã®ã©ã³ãã ãªã»ã¯ã·ã§ã³ãéžæãã枬å®ãè¡ãããã®çµæã®æŠèŠã説æã§ããŸãã ããã¯ããã»ã©æ£ç¢ºã§ã¯ãããŸããããããå°ãªã枬å®ãè¡ãå¿ èŠããããŸãã
ããã¯ãããèªäœãæé¡ããæèã§ããããšã«ããã«æ°ä»ãããšãã§ããŸãããå€æ¬¡å ã®å±±ã次å æ°ã®å¢å ãšãšãã«æé·ãå§ãããšããããã¯ããŸã圹ã«ç«ã¡ãŸããã å±±ã®è¡šé¢ã¯ã<次å ã®æ°>ã®çšåºŠã®<1ã€ã®æ¬¡å ã®å€ã®æ°>ã«çããããšãæãåºããŠãã ããã ãµã³ããªã³ã°ã¯æ¬¡æ°ã®åºç€ãæžããã®ã«åœ¹ç«ã¡ãŸãããææ°ã¯ã©ãã«ãè¡ãããåé¡ã¯ææ°é¢æ°ã®ãŸãŸã§ãã
èšç»2ïŒè¿äŒŒ
å±±ã枬å®ããäž»ãªåé¡ã¯ãå±±ã倧ããããšã§ã¯ãããŸããïŒæž¬å®åæ°ã®ç¹ã§ïŒ-æåŸã«ãWikipediaã®åŒã«åŸã£ãŠã1000次å ã®ãªã¬ã³ãžã®ããªã¥ãŒã ãããã»ã©å°é£ãªãèšç®ããŸããã åé¡ã¯ãå±±ã®å ¬åŒããªãããšã§ã ã å±±ãæé·ããåæèŠåã¯ããããŸããïŒãªã¬ã³ãžãšã¯ç°ãªãããã¹ãŠã®æ¹åã«åçã«æé·ããŸãïŒã
ããŠãç§ãã¡ãæ¢ããŠãããã®ã«äŒŒãŠããããä»åºŠã¯åŒã䜿çšããŠãç¬èªã®å¥ã®å±±ãæ§ç¯ãããšã©ããªããŸããïŒ ãã®ãããªãã®ïŒ
ãŸã...å®éã«æªéã¯åœŒãç¥ã£ãŠããŸãã 第äžã«ãããã¯ãŸã ããŸãæ確ã§ã¯ãªããè¿äŒŒã¯éåžžã«æ£ç¢ºã§ããå¯èœæ§ããããŸã-åçã§ã¯ããŸãè¯ãèŠããŸããã 第äºã«ããããè¡ãæ¹æ³ããŸã ããããŸããã ãããå§ããŸãããã
ã©ãã©ã¹è¿äŒŒ
ããäžåºŠããã€ãºã®å®çãå°ãã ãç°ãªãæ¹æ³ã§æããŸãã
åæ°ã®å³åŽã«ãã2ã€ã®ç¢ºçã®ç©ã1ã€ã«ãŸãšããŸãããããããçµå確çïŒãããŠãããäžåºŠãè¡šèšãã·ãŒã¿ã§ã¯ãªãwã«ãããã«å€æŽããããšãæãåºããŸãïŒã 人ã ã¯ãã°ãã°ããã次ã®æå³ã§èŠã -ãæãŸãããé åžãããã³ çµæã1ã«åèšããããã«å¿ èŠãªæ£èŠåå®æ°ã§ãã äžæçã«æ€çŽ¢ã«éäžããŸããã ã
ãã€ã©ãŒçŽæ°ãæãåºããŠãã ãã ã 解æã®æåã®ã³ãŒã¹ã«åŸã£ãŠãä»»æã®é¢æ°ãç¡ééã®å®çŸ©ãããå€é åŒã«å解ãããŸãã é¢æ°ãæžã ã©ããã£ãŠ ããããŠç§ãã¡ã¯ããæç¹ã§ã¬ã€ã¢ãŠãããŸã ãããã¯æ倧ååžãšäžèŽããŸãïŒã©ãã«ãããã¯ããããŸããããããã¯ãŸã éèŠã§ã¯ãããŸããïŒã åæã«ãçšèªã®åŸã«2ã®ã¹ãä¹ã§ç¡éã®éãåãæšãŠãŸãã
ïŒããã¯ãWikipediaããã®1察1ã®çŽæ¥çãªå»æ¢ããããã€ã©ãŒæ¡åŒµã§ãïŒ
ä»ãç§ãã¡ãéžãã ããšãèŠããŠãããŠãã ãã æ倧ç¹ãšããŠãããã¯ãã®äžã®åŸ®åããŒãã«çããããšãæå³ããŸãã ã€ãŸãã2çªç®ã®çšèªã¯æ確ãªè¯å¿ããã£ãŠæšãŠãããšãã§ããŸãã ååŸããŸã
äœã«ã䌌ãŠããŸãããïŒ å®éããã®ããšã¯ã¬ãŠã¹ã®å¯Ÿæ°ãšåã圢ãããŠããŸãã ãããèŠãããã«ãããªãã¯æžãããšãã§ããŸã
è¡šèšãå°ãå€æŽããŠã¿ãŸãããã ãããŠä»ããããããŸã ã ãããã ããããŠãææã®çµå確çã¯ãæ倧ç¹ãšæšæºåå·®ã«äžå¿ãããã¬ãŠã¹ã«ãã£ãŠè¿äŒŒã§ããããšãããããŸã ïŒæ倧ç¹ãŸãã¯æ²çã§ã®éäºæ¬¡å°é¢æ°ïŒã
1ã€ã®ã»ã¯ã·ã§ã³ã«ãããŸããªæåãå€ãããå Žåã¯ã3ã€ã®çããã©ã°ã©ãã§ã¢ã€ãã¢ãèŠçŽããŸãã ãããã£ãŠãå±±ã®ããªã¥ãŒã ãæ€çŽ¢ããå Žåã¯ã次ã®ãã®ãå¿ èŠã§ãã
-æ倧ãã€ã³ããèŠã€ãã
-ãã®äžã®æ²çã枬å®ããŸãïŒäºæ¬¡å°é¢æ°ãèšç®ããŸã;å¯äžã®æ³šæïŒã«é¢ãã埮å ãããã§ã¯ãªã ïŒ
-æ倧ç¹ãšæšæºåå·®ãäžå¿ãšããæ³ç·æ²ç·ãåããŸã-æ²çã«è² ã®åæ¯äŸã
å±±ã®ããŒã¯ãã€ã³ããæ€çŽ¢ããããšãã§ãããã¹ãŠã枬å®ãããããã¯ããã«ç°¡åã§ãã å®éãååã®æçš¿ã§ãã¡ããã¡ãã«ããã®ãšåããã€ãžã¢ã³ååž°ã«éæ³ããããŸãããïŒ
æåŸã®æçš¿ã®æåŸã§æ倧ç¹ãæ€çŽ¢ããŸãã-ããã¯ããã€ãžã¢ã³ãã³ãã«ã®äžå¿ããæãããããªç·ããªã©ã§ãã 念ã®ãããããäžåºŠèŠã€ããæ¹æ³ã説æããŸããããã©ãŒãã¥ã©ã§äººã ãæããããªãããã«ãã¹ãã€ã©ãŒã®äžã«é ããŸãã
ãã¿ãã¬èŠåºã
ããã§ãargmaxã®äžã®æåã®éšåã¯å°€åºŠã§ããã2çªç®ã¯ã¬ãŠã¹äºåååžã§ãã 補åã¯ãéåžžã®ããã«å¯Ÿæ°ããšã£ãŠéã«å€æãããŸããã
ããã§ãargmaxã®äžã®æåã®éšåã¯å°€åºŠã§ããã2çªç®ã¯ã¬ãŠã¹äºåååžã§ãã 補åã¯ãéåžžã®ããã«å¯Ÿæ°ããšã£ãŠéã«å€æãããŸããã
ã®èªå°äœ åæçã«æ°ããããšãã§ããŸãããç§ã¯ã²ã©ãã«ãŠãããããªã®ã§ãç§ã¯ããããã¹ãŠPythonã«å ¥ããŠãaurogradã«ç§ã®ããã«ä»äºãããããã§ãã
# b w , # ext_w = np.hstack([b, w]) # # , ext_data.dot(ext_w) # data.dot(w) + b ext_data = np.ones((data.shape[0], data.shape[1] + 1)) ext_data[:, 1:] = data # log joint, # def log_joint(w): regression_value = ext_data.dot(w) return ( np.sum(-np.power(target - regression_value, 2.) / (2 * np.power(1., 2.))) + np.sum(-np.power(w, 2.) / (2 * np.power(1., 2.))) ) from autograd import elementwise_grad second_grad_log_joint = elementwise_grad(elementwise_grad(log_joint)) mu = ext_w sigma = -1. / second_grad_log_joint(ext_w) cov = np.diag(sigma) # , # some_value = multivariate_normal.pdf(some_point, mu, cov)...
ãã£ã¹ããªãã¥ãŒã·ã§ã³ãããå Žåããããæãããšã¯æè¡çãªåé¡ã§ãã ãã¹ãã®æåŸã®éšåãšã»ãŒåãæ¹æ³ãå°ãå€æŽããŠäœ¿çšããŸãïŒäžå¿ããã®è·é¢ãç°ãªããµã³ãã«ååžïŒã ãããªçŽ æµãªåçãåŸãããŸãïŒ
ãšããã§ãããã®ãã¹ãŠã®æ²ç·ã¯15次ã®å€é åŒã§ãã æã®ã匷åŒãªããã€ãžã¢ã³ååž°ã¯ãæ°å¹Žåããã³ã³ãã¥ãŒã¿ãŒæ代ã«æ»ã£ãŠããŸããïŒã©ããããããã5床ãçµããŸããïŒã
ã©ãã©ã¹è¿äŒŒã¯ãã¹ãŠã®äººã«é©ããŠããŸã-é«éã䟿å©ãçŸãã-ãããã1ã€æªãç¹ããããŸããããã¯æ倧ç¹ã§æšå®ãããŸãã ããã¯å±±å šäœã§å€æãããããªãã®ã§ãé äžããèŠããã®ã§ã-æ¬åœã«é äžã«ããã®ãããããšãå±æçãªæ倧å€ã«çãŸã£ãŠããã®ãããããªããšããäºå®ãšããããããã¹ãŠãèŠããããã§ã¯ãªããšããäºå®ã«ããããããïŒçªç¶ããã¹ãŠãéåžžã«å¹³ãã§çŸããããã®äžã«3ããã¡ãŒãã«ã®æåŽçµ¶å£ããããŸããïŒïŒ äžè¬ã«ã圌ãã¯ãã¥ãŒã©ã«ãããã¯ãŒã¯ã®ããã«ãããæãã€ãããããªããæšæž¬ãããããããªããã©ãã©ã¹ã®æã§ã¯ãªãã1991幎ã§ããããã以æ¥ãããã¯å®éã«äžçã«åã£ãŠããªãã ããã§ã¯ããã£ãšãã¡ãã·ã§ããã«ã§çŸãããã®ãèŠãŠã¿ãŸãããã
backpropã«ãããã€ãºïŒéå§
æåŸã«ãDeepMindã®ã¿ã€ãã«èšäºãããŸãã«ãã®æ¹æ³ã«å°éããŸããã èè ã¯ãbackpropã§BayesãšåŒãã§ããŸã-ãã·ã¢èªãžã®ç¿»èš³ã§å¹žéãç¥ããŸãã éãã€ãºäŒæ¬ïŒ
ããããã®åºçºç¹ã¯ããã§ããããçš®ã®è¿äŒŒããããšæ³åããŠãã ãã ïŒããã¯ã·ãŒã¿èšå·ã䟿å©ãªå Žæã§ã-ãããã¯è¿äŒŒååžãã©ã¡ãŒã¿ã«ãªããŸãïŒããããäœããã®åçŽãªåœ¢åŒãããšãã°ã¬ãŠã¹åã«ããŸãã ç§trickã¯æ¬¡ã®ãšããã§ããå ã®å±±ã®è¿äŒŒå€ããã®ãè·é¢ãã®è¡šçŸãæžãçãããã®è·é¢ãæå°åããŸãã äž¡æ¹ã®éã確çååžã§ãããããååžãæ¯èŒããããã«ç¹å¥ã«èæ¡ããããã®ãçµåããŸãïŒ ã«ã«ããã¯ã»ã©ã€ãã©ãŒè·é¢ ã å®éãå°ãæãããã«èãããŸãããããã ãã§ãïŒ
ç©åã泚ææ·±ãèŠããšããããæåŸ ã®ããã«èŠããããšãæããã«ãªããŸã-ç©åã®äžã«ã¯ãããçš®ã®ãã®ãããã ããããŠç©åãåŒãç¶ãããŸã ã ãã®åŸã次ã®ããã«èšè¿°ã§ããŸãã
ããã«é²ãã§ãã ããïŒåæ¯ã« ããããŠããã€ãºã®å®çã«ããã ã äžèšã®åŒã«å ¥ããŠãæåŸ ã®äžã«ããããšã«æ³šæããŠãã ãã -ã«äŸåããªã ããããŠç§ãã¡ã¯ãããæåŸ ããå€ãããšãã§ããŸãïŒ
ããã¯ãšãŠãã¯ãŒã«ãªããšã§ããã ããªããå¿ããŠããªããªãããã®å šäœã¯è¿äŒŒå€ãšç§ãã¡ã®å±±ã®å·®ã«çããããã§ãã ããã§ç®¡çããããã©ã¡ãŒã¿ãŒã¯ ããããŠå·®ãæå°ã«ãªãããã«èª¿æŽããããšæããŸãã ãããã£ãŠããã®æå°åã®ããã»ã¹ã§ã¯ãå¿é ããå¿ èŠã¯ãããŸããã
-ããã¯ã«äŸåããªããã ã ã¡ãªã¿ã«ãããã¯åŸéšã®äž»ãªåé¡èŠçŽ ã§ãã-èšç®ããããã«ã¯ãå±±ã®ãã¹ãŠã®ãã€ã³ããåã£ãŠããããããŸãšããå¿ èŠããããŸããïŒãªããªã ããã¹ãŠã®é ãä»ã®æ¹æ³ã§å ¥æããããšã¯ã§ããŸããïŒã
ããããå ã«é²ã¿ãŸãã æ®ã£ãŠãããã®ã®æå°å€ãèŠã€ããããšã«é¢å¿ããããŸãã
éåžžãã©ã®ããã«äœå€ãæ¢ããŸããïŒ ããŠãå°é¢æ°ãåããåŸé éäžãè¡ããŸãã ãã®ãŽããã掟çç©ãååŸããæ¹æ³ã¯ãããŸããïŒ ä»ã®ãšããããŸãè¯ããªãããšããããŸãã
backpropã«ãããã€ãºïŒç¶ã
ããã«ç§ãçŽæçã«å ¥åããããšãã§ããªãã£ãéšåãæ¥ãã®ã§ãæ¯ã磚ããŠæ°åŠã«åŸãå¿ èŠããããŸãã å°é¢æ°ãååŸã§ããéšåã¯ãåãã©ã¡ãŒã¿ãŒåããªãã¯ãšåŒã°ãã次ã®æé ã§æ§æãããŸãã
- ã©ã³ãã å€æ°ãåã£ããšããŸããã ã 圌女ã«ã€ããŠã¯äœãç¥ããªã ã ããã圌女ã®è²¡ç£ã§ããããããŸã§ã®ãšãã圌女ã«é¢ãããã¹ãŠã§ãã
- äžè¬çã«èšãã°ãæåŸ ã®å°é¢æ°ã¯èŠããã»ã©ã²ã©ããã®ã§ã¯ãããŸãããããã¯åã«ç©åã®å°é¢æ°ãã€ãŸã倧ãŸãã«èšã£ãŠãåèšãçµãã£ãåèšã®å°é¢æ°ã§ã ã ããèªäœã¯æããããããŸããããéå±ã§ãããç¡éã«æé·ãããã¹ãŠã®ãã€ã³ãããŸãšããããšããåé¡ã«åã³æ»ãããã§ãã ãã äžè¬çãªçšèªã§ãæåŸ ã®äžã§äœããã®æ©èœãæ³åããŠã¿ãŸããã ãããªããã£ããèšè¿°ããŸãã
ç§ãã¡ã¯ç¹å¥ãªããšã¯äœãããŸããã§ãã-ãŠã£ãããã£ã¢ããã®å®çŸ©ã«ãã£ãŠæåŸ ãéãããããäžå¯æ¬ ãªãã®ãšããŠåã³æžãçããŸããã ã§ãã æåŸã«ïŒ ç§ãã¡ã¯ã¡ããã©ãããçãããšèšã£ã ã ãããŠ...
ä»ãç©åã¯ã€ãã·ãã³äžã§è¡ãããŸããã€ãŸãã埮åã
ç©åã®ç¬Šå·ã®äžã§ã
ããã«ãåãã©ã¡ãŒã¿åã®ããªãã¯ããããŸããæåŸ ã®å°é¢æ°ãããããããå°é¢æ°ã®æåŸ ã«ãªããŸããã ãã£ããã ããããªãããŸã ãã£ãããšç§ã®æã®ã¬ã€ãã«åŸã£ãŠãããªããããªãã¯ããŸãã¯ãŒã«ã§ã¯ãªããããããäœãå€ãã£ãã®ãããæ確ã§ã¯ãªãã§ããã-ç§ãã¡ã¯1ã€ã®FIGãçµ±åããå¿ èŠããããŸã ç§ãã¡ã¯äœãéæããŸãããïŒ
äžçªäžã®è¡ã¯ãããã€ãã®ç¹ïŒãµã³ãã«ïŒã§ãã®ç©åãè¿äŒŒã§ããããšã§ãã ãããŠã圌ããã§ããªãã£ãåã«ã 以åã¯ãããªããã£ãã¯å šé¡ããååŸããå¿ èŠããããŸããããŸããäžé£ã®ãã€ã³ãããŸãšããŠããããããåºå¥ããŸããã³ã¬ã¯ã·ã§ã³å ã®äžæ£ç¢ºãã¯ãå·®å¥åããéã«ãã¯ããã«ééã£ãæ¹åã«ç§ãã¡ãå°ãå¯èœæ§ããããŸãã ãããŠä»ãç§ãã¡ã¯ç¹ã§åºå¥ããçµæãèŠçŽããããšãã§ããŸã-ãããã£ãŠãéšåçãªåèšã§ããªãã§ããŸãã
è¿äŒŒæšè«ã®äžçã«ããããã®ãããªå³ããé åºã¯æ¬¡ã®ãšããã§ããããã§ã¯ãäºåŸååžèªäœã§ãªãã å°é¢æ°ãèšç®ããããã®è¿äŒŒãå¿ èŠã§ãã ãŸããäœããç§ãã¡ã¯ã»ãšãã©ããã«ãããŸãã
backpropã«ãããã€ãºïŒã¢ã«ãŽãªãºã
ãããŸã§ã®ãšãããç§ãã¡ã¯ã«å±ããŠãã æœè±¡çãªããã©ã¡ãŒã¿ããšããŠïŒããããæ確ã«ããæãæ¥ãŸããã è¿äŒŒãã㊠ã¬ãŠã¹ã«ãªããŸãïŒãããŠæ³åããŠãã ãã 圢㧠-å¹³åå€ãããã³ -æšæºåå·®ã ãŸãã決å®ããå¿ èŠããããŸã -ãŒããšæšæºåå·®1ãäžå¿ãšããã¬ãŠã¹ç¢ºçå€æ°ã«ããŸãããã ã 次ã«ãåãã©ã¡ãŒã¿ãŒåã®æ¡ä»¶ãæºããããããã«ã
ïŒ ããã§ã¯ãèŠçŽ ããšã®ä¹ç®ãæå³ããŸãïŒã ããããç§ã«ãšã£ãŠã¯ããªãåæã« ïŒãã誰ããèªåã®æã®ã³ã¡ã³ãã§èª¬æã§ãããªã-ç§ã¯éåžžã«æè¬ããŸãïŒããããç§ãã¡ã¯ä¿¡ä»°ã«é¢ããèšäºã®ãã®éšåãåããŸãã
å šäœãšããŠãéååžã¯æ¬¡ã®æé ã§æ§æãããŸãã
- ã©ã³ãã ã§éå§ ãã㊠åãã¥ãŒã©ã«ãããã¯ãŒã¯ã®éã¿ïŒãŸãã¯ååž°ä¿æ°ïŒ
- å°ããµã³ãã« ãã
- ç§ãã¡ã¯ããããåŸã
- ãçã®å±±ããšè¿äŒŒéã®è·é¢ã®é¢æ°ãæãåºããŸãã ãã€ãŠ ããããè¯ãæå³ã§ãã ã ãšã«ããäžã«æžããŸã ãããã¯ç°¡åã§ãïŒèŠããŠãããŠãã ãã ïŒ
- ã«ã€ããŠã®åŸ®åãèæ
®ãã ã 次ã®ããã«ãªããŸãã
ïŒãã©ã¹ã¯ã©ãã§ããïŒ 2ã€ã®å€æ°ã®é¢æ°ã§ãããäž¡æ¹ãäŸåããŸã ïŒ
- ã«ã€ããŠã®åŸ®åãèæ
®ãã ïŒ
- 掟çç©ããããŸã-ããã¯æ¯hatçã«åžœåããã¶ã£ãŠããŸãã ããã«å€ãè¯ãåŸé
éäžæ³ïŒ
ãã¹ãŠã®çµæ
ããªãã®ããšã¯ç¥ããŸãããããã®é»ãšé»è²ã®ããŒã ã«ã¯ããããããããŠããã®ã§ããã®å¿ é ã®æ®µéãã¹ãããããŠããã¥ãŒã©ã«ãããã¯ãŒã¯ã®ãããªããšãããŸãããã å ã®èšäºã®èè ã¯ãç³ã¿èŸŒã¿ãããã¯ãŒã¯ã䜿çšãããªã©ã®è¿œå ã®æªã¿ãªãã«ãMNISTæ°åã§çŽ æŽãããçµæãåŸãŸãã-ãããã«å°éããŠã¿ãŸãããã ãããŠãããããããªãã®èªååæ¥çãèã«çœ®ãããã¢ãã®ãããªãã£ãšéããã®ã§æŠè£ ããæãæ¥ãã®ã§ãããã ãã®åŸãTheanoåºæã®ã³ãŒããå°ãããã®ã§ããããããã²ãŒãããªãå Žåã¯ãèªç±ã«ããããŸãã
ããŒã¿ãååŸããŸãã
from sklearn.datasets import fetch_mldata from sklearn.cross_validation import train_test_split from sklearn import preprocessing import numpy as np mnist = fetch_mldata('MNIST original') N = 5000 data = np.float32(mnist.data[:]) / 255. idx = np.random.choice(data.shape[0], N) data = data[idx] target = np.int32(mnist.target[idx]).reshape(N, 1) train_idx, test_idx = train_test_split(np.array(range(N)), test_size=0.05) train_data, test_data = data[train_idx], data[test_idx] train_target, test_target = target[train_idx], target[test_idx] train_target = np.float32(preprocessing.OneHotEncoder(sparse=False).fit_transform(train_target))
ãã©ã¡ãŒã¿ãŒã宣èšããŸãã ããã§ã¯ãèšäºã«èšèŒãããŠããå°ããªããªãã¯ãé©çšããŸãããç§ã¯æ æã«äŒããŸããã§ããã åé¡ã¯ããã§ããåãããã¯ãŒã¯ã®éã¿ã«å¯ŸããŠãmuãšsigmaã®2ã€ã®ãã©ã¡ãŒã¿ãŒããããŸãã sigmaã¯åžžã«ãŒãããã倧ãããªããã°ãªããªããšããäºå®ã§ãå°ããªåé¡ãçºçããå ŽåããããŸãïŒããã¯ã¬ãŠã¹ã®æšæºåå·®ã§ãããå®çŸ©ã«ãã£ãŠè² ã«ãªãããšã¯ã§ããŸããïŒã ãŸããã©ã®ããã«åæåããã®ã§ããïŒ ããŠã0ã«éåžžã«è¿ãå€ïŒ0.0001ãªã©ïŒãã1ãŸã§ã®ä¹±æ°ã䜿çšã§ããŸãã 第äºã«ããŒã以äžã®åŸé éäžäžã«åæ¢ããŸãããïŒ ããããããããã¹ãã§ã¯ãããŸããããããããçš®é¡ã®ç®è¡çãªäžæ£ç¢ºãã®ããã«ãå°æ°ç¹ã¯ãããããããŸããã äžè¬çã«ãèè ã¯ããããšã¬ã¬ã³ãã«è§£æ±ºããããšãææ¡ããŸãã-ã·ã°ããã·ã°ãã®å¯Ÿæ°ã«çœ®ãæããéã¿ã®å ¬åŒãé©åã«ä¿®æ£ããŸãïŒ
ïŒãªãããã§+1察æ°ã®äžã«ããã®ã§ããããïŒæããã«ãåãç®çã§-誀ã£ãŠå¯Ÿæ°ããŒãããåããªãããã«ïŒã
ããããŸããç§ãã¡ã¯ãã€ãã¹ã±ãŒã«ã«ã€ããŠè©±ããŸãã ãããããã¥ãŒã©ã«ãããã¯ãŒã¯ã§ã¯ãå€ãã®å Žåãç¬èªã®åœåæ³-ãŒããŠã§ã€ãã ããã«åŒã°ãã ïŒãã€ã¢ã¹ïŒã ç§ãã¡ã¯å¥çŽã«éåããŸããã ã ããïŒ
def init(shape): return np.asarray( np.random.normal(0, 0.05, size=shape), dtype=theano.config.floatX ) n_input = train_data.shape[1] # L1 n_hidden_1 = 200 W1_mu = theano.shared(value=init((n_input, n_hidden_1))) W1_logsigma = theano.shared(value=init((n_input, n_hidden_1))) b1_mu = theano.shared(value=init((n_hidden_1,))) b1_logsigma = theano.shared(value=init((n_hidden_1,))) # L2 n_hidden_2 = 200 W2_mu = theano.shared(value=init((n_hidden_1, n_hidden_2))) W2_logsigma = theano.shared(value=init((n_hidden_1, n_hidden_2))) b2_mu = theano.shared(value=init((n_hidden_2,))) b2_logsigma = theano.shared(value=init((n_hidden_2,))) # L3 n_output = 10 W3_mu = theano.shared(value=init((n_hidden_2, n_output))) W3_logsigma = theano.shared(value=init((n_hidden_2, n_output))) b3_mu = theano.shared(value=init((n_output,))) b3_logsigma = theano.shared(value=init((n_output,)))
ãã®ãã°ã·ã°ãã¯ãã©ããããããæ£èŠååžåŒã«ããã·ã¥ã§ããå¿ èŠããããããç¬èªã®é¢æ°ãäœæããŸãã åæã«ãéåžžã®ãã®ã宣èšããŸãïŒ
def log_gaussian(x, mu, sigma): return -0.5 * np.log(2 * np.pi) - T.log(T.abs_(sigma)) - (x - mu) ** 2 / (2 * sigma ** 2) def log_gaussian_logsigma(x, mu, logsigma): return -0.5 * np.log(2 * np.pi) - logsigma / 2. - (x - mu) ** 2 / (2. * T.exp(logsigma))
確çãè©äŸ¡ãããšãã§ãã 以åã«åéããããã«ããµã³ããªã³ã°ã«ãã£ãŠãããè¡ããŸããã€ãŸããã«ãŒãã§ã¹ãã³ããå埩ããšã«ã©ã³ãã ã«åæåããã€ãã·ãã³ãååŸãããããéã¿ã«å€æããŠçµã¿åãããŸãã äžè¬ã«ãTheanoã«ã¯ã«ãŒãã®ã¹ãã£ã³ããããŸããã1ïŒãŠãŒã¶ãŒã®è³ãå¯èœãªéãç Žå£ããããšãç®çã«ãmanæ¢ç©¶è ã®ããŒã ã«ãã£ãŠæ確ã«éçºãããŸããã2ïŒå°æ°ã®å埩ã§ãéåžžã®ã«ãŒããæ©èœããŸãã åèšïŒ
n_samples = 10 log_pw, log_qw, log_likelihood = 0., 0., 0. for _ in xrange(n_samples): epsilon_w1 = get_random((n_input, n_hidden_1), avg=0., std=sigma_prior) epsilon_b1 = get_random((n_hidden_1,), avg=0., std=sigma_prior) W1 = W1_mu + T.log(1. + T.exp(W1_logsigma)) * epsilon_w1 b1 = b1_mu + T.log(1. + T.exp(b1_logsigma)) * epsilon_b1 epsilon_w2 = get_random((n_hidden_1, n_hidden_2), avg=0., std=sigma_prior) epsilon_b2 = get_random((n_hidden_2,), avg=0., std=sigma_prior) W2 = W2_mu + T.log(1. + T.exp(W2_logsigma)) * epsilon_w2 b2 = b2_mu + T.log(1. + T.exp(b2_logsigma)) * epsilon_b2 epsilon_w3 = get_random((n_hidden_2, n_output), avg=0., std=sigma_prior) epsilon_b3 = get_random((n_output,), avg=0., std=sigma_prior) W3 = W3_mu + T.log(1. + T.exp(W3_logsigma)) * epsilon_w3 b3 = b3_mu + T.log(1. + T.exp(b3_logsigma)) * epsilon_b3 a1 = nonlinearity(T.dot(x, W1) + b1) a2 = nonlinearity(T.dot(a1, W2) + b2) h = T.nnet.softmax(nonlinearity(T.dot(a2, W3) + b3)) sample_log_pw, sample_log_qw, sample_log_likelihood = 0., 0., 0. for W, b, W_mu, W_logsigma, b_mu, b_logsigma in [(W1, b1, W1_mu, W1_logsigma, b1_mu, b1_logsigma), (W2, b2, W2_mu, W2_logsigma, b2_mu, b2_logsigma), (W3, b3, W3_mu, W3_logsigma, b3_mu, b3_logsigma)]: # first weight prior log_pw += log_gaussian(W, 0., sigma_prior).sum() log_pw += log_gaussian(b, 0., sigma_prior).sum() # then approximation log_qw += log_gaussian_logsigma(W, W_mu, W_logsigma * 2).sum() log_qw += log_gaussian_logsigma(b, b_mu, b_logsigma * 2).sum() # then the likelihood log_likelihood += log_gaussian(y, h, sigma_prior).sum() log_qw /= n_samples log_pw /= n_samples log_likelihood /= n_samples
ãµãã ä»ãç§ãã¡ã¯ç®çãéããŸãã èšäºã®ãã®å Žæã®ã©ããã§2é±éäŒæ¢ããå¿ èŠããããŸããããã¯ãèšäºã§ææ¡ãããŠããç®æš
(log_qw - log_pw - log_likelihood / M).sum()
ãããªãã®ïŒãæ©èœããªãã£ããããæªãçµæã ããããããæç¹ã§ãç§ã¯ãã®èšäºãæåŸãŸã§èªãããšã«ããèè ã¯ãããããã䜿ã£ãŠç¹å®ã®æ¹æ³ã§ç®æšãå¹³ååããããšãå§ããŠããããšã«æ°ä»ããŸããã ããæ£ç¢ºã«ã¯ããã®ããã«ã§ãïŒ
objective = ((1. / n_batches) * (log_qw - log_pw) - log_likelihood).sum() / batch_size
åæã«ã圌ãã¯éåžžã®åŸé éäžã®ä»£ããã«Adamãªããã£ãã€ã¶ãŒã䜿çšããããšãå§ããŸããã ç§ã¯äººçã§äœ¿ã£ãããšããªãã®ã§ãèªåã§æžããŠæ¢è£œã®ãã®ã䜿ãèªæã«æµæããŸãã
from lasagne.updates import adam all_params = [ W1_mu, W1_logsigma, b1_mu, b1_logsigma, W2_mu, W2_logsigma, b2_mu, b2_logsigma, W3_mu, W3_logsigma, b3_mu, b3_logsigma ] updates = adam(objective, all_params, learning_rate=0.001)
ããŠããããããã¹ãŠãæšæºã§ã-åè»æ©èœãšçŽæ¥å匷ã«è¡ããŸãã ãã¹ãŠã®ã³ãŒãã¯ããã«ãããŸã ã éåžžã«é«ãããŒã»ã³ã粟床ã¯ããã§ã¯æ©èœããŸããããæ¬åœã§ãããããããã³ã§ãã
ãšããã¯0ã³ã¹ã6.83701634889粟床0.764 ãšããã¯1ã³ã¹ã-73.3193287832粟床0.876 ãšããã¯2ã³ã¹ã-89.2973277879粟床0.9 ãšããã¯3ã³ã¹ã-95.9793596695粟床0.924 ãšããã¯4ã³ã¹ã-100.416764595粟床0.924 ãšããã¯5ã³ã¹ã-104.000705026粟床0.928 ãšããã¯6ã³ã¹ã-107.166556952粟床0.936 ãšããã¯7ã³ã¹ã-110.469004896粟床0.928 ãšããã¯8ã³ã¹ã-112.143595876粟床0.94 ãšããã¯9ã³ã¹ã-113.680839646粟床0.948
ã¬ãŠã¹è¿äŒŒããããè€éãªãã®ã«ç§»è¡ããæ¹æ³ããŸãã¯åŒ·ååŠç¿ã§ãã®æ¹æ³ã䜿çšããæ¹æ³ïŒæåŸã«ããããDeepMindã§ãïŒããŸã ããã®ã§ã 念ã®ããã«ãèšäºãžã®ãªã³ã¯ãæ®ããŠãããŸãçµäºïŒã
QïŒA
- ãå€åããšããèšèã¯ãèšäºã®ã©ãã§ãäžè¬çã«äœ¿çšãããŠããŸãããæçš¿ã§ã¯ããã«ã€ããŠäœãèšãããŠããŸããã
ããã§ãæ¥ããããããšã«ãç§ã¯ãã æ¥ããããã£ãã§ããåŠæ ¡ã§ã¯ãããªãšãŒã·ã§ã³ã®èšç®æ³ãæã£ãŠããªãã£ãã®ã§ãç¹ã«éŠŽæã¿ã®ãªãçšèªã䜿ãããšã«ã¯å°ãèŠæããŠããŸããã ããããäžè¬çã«ã¯ã¯ãã å€åãã€ãºæ³ã®ã»ã¯ã·ã§ã³ã§äžè¬çãªã¢ãããŒãã«ã€ããŠèªãããšãã§ããŸãã æã§ã¯ãç§ãç解ããŠããããã«ãååã®æå³ã¯ããã§ãïŒããªãšãŒã·ã§ã³ã®èšç®ã¯ãæ°åã䜿çšããéåžžã®åæãšåãããã«é¢æ°ã§æ©èœããŸãã ã€ãŸããåŠæ ¡ã§é¢æ°ã®æå°å€ãéæããããã€ã³ããæ¢ãããšããã§ãããã§é¢æ°ãæ¢ããŠããŸã ïŒ ïŒãããšãã°ãKLã®çºæ£ãæå°åããŸãã - æåŸã®æçš¿ã§è³ªåããããŸãã-ãããã ããããã¢ãŠãã¯äžè¬çã«ãããšäœã®é¢ä¿ããããŸãããããã¯äœããã®åœ¢ã§ãã®ãã¹ãŠã®ããžãã¹ã«é¢é£ããŠããŸããïŒ
ãã®ããã«ã ããããã¢ãŠãã¯ããã€ãžã¢ã³äž»çŸ©ã®å®äŸ¡ãªããŒãžã§ã³ãšèããããšãã§ããŸããããã¯éåžžã«åçŽã§ãã ãã®ã¢ã€ãã¢ã¯ãååã®æçš¿ã®æåŸã§èšåããã¢ã³ãµã³ãã«ãšåãã¢ãããžãŒã«åºã¥ããŠããŸãïŒãã¥ãŒã©ã«ãããã¯ãŒã¯ããããšæ³åããŠãã ããã ä»ãããªãããããåãã誀ã£ãŠããã€ãã®ãã¥ãŒãã³ãåŒãå¥ãããèã«çœ®ãããšæ³åããŠãã ããã ãã®ãããªæäœãçŽ1000åå®è¡ãããšãæ°åã®ãããã¯ãŒã¯ã®ã¢ã³ãµã³ãã«ãåŸãããŸããåãããã¯ãŒã¯ã¯ãäºãã«ã©ã³ãã ã«ãããã«ç°ãªããŸãã ãããã®äºæž¬ãå¹³åãããšãå Žæã®ã©ã³ãã ãªåå·®ãäºãã«æã¡æ¶ãåããå®éã®äºæž¬ãåŸãããããšãããããŸãã ããã§ããã€ãžã¢ã³ãããã¯ãŒã¯ãããããã®éã¿ã®ã»ãããäžç¢ºå®æ§ããæ°åååãåºãããããã«ç°ãªããããã¯ãŒã¯ã®åãã¢ã³ãµã³ãã«ãååŸãããšããŸãã
ãã€ãžã¢ã³ã¢ãããŒããããæ¥ã§ã-ãã®ã©ã³ãã æ§ãå¶åŸ¡ãããæ¹æ³ã§äœ¿çšã§ããŸãã ããäžåºŠåçãèŠãŠãã ããïŒ
ããã®åéã¿ã¯ã©ã³ãã å€æ°ã§ããããããã®äºæ ã¯ç°ãªããŸãã ã¬ãŠã·ã¢ã³ã®ããŒã¯ã¯ã©ããã§å·Šã«åŒ·ãã·ããããã©ããã§å³ã«ã·ããããã©ããã§äžå€®ã«ããã倧ããªåæ£ãæã£ãŠããŸãã ããããããã¬ãŒãã³ã°ã®çµæãšããŠãåéã¿ã¯ããããã¯ãŒã¯ããã®ã¿ã¹ã¯ãå®è¡ããã®ã«æé©ãªãã©ãŒã ãååŸããŸãã ã€ãŸããããšãã°éåžžã«éèŠãªéã¿ãããå Žåãããã¯å³å¯ã«çãããªããã°ãªããŸãããããããªããšããããã¯ãŒã¯å šäœãç Žæããéã¿ããµã³ããªã³ã°ãããšãã«ããã®ãã¥ãŒãã³ããã®ãŸãŸæ®ãå¯èœæ§ãé«ããªããŸãã ããããã¢ãŠãã®å ŽåããŠã§ã€ããåçã«ã©ã³ãã ã«ãªãã«ããã ãã§ããã®éèŠãªãŠã§ã€ããç°¡åã«åŒ·æã§ããŸãã ããããã¢ãŠãã¯ããã®ãéèŠæ§ãã«ã€ããŠäœãç¥ããŸããã圌ã«ãšã£ãŠããã¹ãŠã®éã¿ã¯åãã§ãã å®éã«ã¯ãããã¯ãDimpindãããã¯ãŒã¯ãããããã¢ãŠãã®ãããããã¯ãŒã¯ãããè¯ãçµæããããããšããäºå®ã§è¡šãããŠããŸãããããã»ã©ã§ã¯ãããŸããã
ããããã¢ãŠãã¯ãŒã©ãŒãåªããŠããã®ã¯ããã¡ããéåžžã«ã·ã³ãã«ã ããã§ãã - äžäœäœããŠãã®ïŒ ããããããã¥ãŒã©ã«ãããã¯ãŒã¯ã¯ãé ã®äžã®ã®ãºã¢ã®ã€ã¡ãŒãžãšèåã«çµã¿èŸŒãŸããã¹ãã§ãã æããã«ã¬ãŠã¹ã®éã¿ã¯ãããŸãããããã·ã³ãªãã¬ãŒã¿ã§ããããªããå®å
šã«ç¡èŠããŠããããšïŒæéä¿æ°ãé¢æ£äº€é£ããã®ä»ã®çç©åŠïŒããããããããŸãã ããªãã®æç§æžãæšãŠãŠæãæ¹ãããïŒ
ç§ããã¥ãŒã©ã«ãããã¯ãŒã¯ã«ã€ããŠèãããã®ã¯ããã®æŽå²çãªé£éãå«ãè¯ãæ¹æ³ã§ãã
- ããæç¹ã§ã人ã ã¯ãäžè¬ã«äžçã®ãã¹ãŠã®æèãšããã»ã¹ããåå å¹æãã®é£éã«æ²¿ã£ãŠçµç¹åã§ãããšèããŸããã äœããèµ·ãã£ãåŸãäœãä»ã®ããšãèµ·ãããŸããããããŠããããäžç·ã«ãªã£ãŠç¬¬äžã®äœãã«åœ±é¿ãäžããŸããã
- 圌ãã¯éåžžã®ãã€ãžã¢ã³ãããã¯ãŒã¯ã®ãããªã·ã³ããªãã¯ã¢ãã«ãæ§ç¯ãå§ãïŒäž»é¡ãšæ··åããªãããã«ïŒããã®ãããªã¢ãã«ã¯ããããçš®é¡ã®ç°ãªã質åã«çããããšãã§ããããšã«æ°ä»ããŸãã"ïŒãããŠãçãã¯ããªãè¯ãã§ãã
- ãããããã®ãããªã¢ãã«ã§ã¯ããã¹ãŠã®å€æ°ãæã§åããå¿ èŠããããŸããã ããæç¹ã§ã ã³ãã¯ã·ã§ããºã ããã£ãŠæ¥ãŠã次ã®ããã«èšããŸãããã©ã³ãã å€æ°ã®æãäœæãããããããã¹ãŠãã€ã³ãããŠãããäœããã®æ¹æ³ã§ãã®ã¢ãã«ããã¬ãŒãã³ã°ããŠãæ£åžžã«æ©èœããããã«ããŸãã
ãããŠããã¥ãŒã©ã«ãããã¯ãŒã¯ãå«ããŠå€æããŸããã 圌ãã¯æ¬åœã«ç§ãã¡ã®é ã®äžã®æ¿¡ããçç©åŠçãããã®ããã§ãã£ãŠã¯ãªããŸãã ã ãããã¯ãèªåèªèº«ã®ã©ããã§äºãã«ãã£ã€ããŠãããã¥ãŒãã³ã®åœ¢ã§ãåå ãšçµæã®æ£ããçµã¿åãããåŸãããã«äœãããŠããŸãã å éšã®åãã¥ãŒãã³ã¯æœåšçãªãèŠå ãã§ãããäœããã®åå ãšãªãäœããã®å€æ°ã§ããããã€ãžã¢ã³ããžãã¯ã¯ãããã®èŠå ãããæçšã«ããã®ã«åœ¹ç«ã¡ãŸãã
åãã¥ãŒãã³ã¯é ã®äžã§äœãããŸããïŒ ã¯ããå°çã¯ç¥ã£ãŠããŸãã ç¹å¥ãªãã®ã¯ãªããããããŸããã - ãã®ãããã¯ã«ã¯ä»ã«äœããããŸããïŒ
ãããããããã®ããšïŒ
- ããªãšãŒã·ã§ã³ãªãŒããšã³ã³ãŒã㌠-ç§ã®æèŠã§ã¯ãã»ãšãã©ã®æã人æ°ã®ããã¢ãã«ã§ãããè¯ãæå³ã§ãç§ã¯ããããå§ããªããã°ãªããŸããã§ããããç§ã¯ãããæ¬åœã«å¥œãã§ããã
- å®éãæ©æ¢°åŠç¿ã®æŽå²ãããå°ã詳ããèŠãŠã¿ããšãåéããå€åè¿äŒŒãçªãåºãŠããŸãã ãã£ãŒããã«ããã³ãã·ã³ ïŒç¹ã«ã©ãã§ã䜿çšãããŠããªãããã§ãããããã¯å®çŸããŠããããã«èŠããŸãïŒããŸãã¯ãšã©ãŒã®éäŒæã®èšèªã§ãã«ããã³ãã·ã³ããªã¡ã€ã¯ããNADEãšåŒã°ãããã®ã§ãã
- å€åçãªãã©ãã¯ããã¯ã¹ -æçš¿ãè¿œå ããã ãã§ã€ãŸãããã®ã§ããããäœã§ãããããç¥ããŸããããç§ã¯ãã§ã«çŽ¹ä»ã®ååãšçŽæã奜ãã§ãã
- DRAW ãããã¯ã©ãããŠãåŸãããªããã®ã§ãé©ãã»ã©ã«èŠããŸããéçã®ããã«æ°åãæãããšãã§ããã¢ãã³ã·ã§ã³ã¡ã«ããºã ãåãããªã«ã¬ã³ããããã¯ãŒã¯ã§ãã
- æåž«ããåŠç¿ãšæåž«ãªãåŠç¿ãçµã¿åãããã©ããŒãããã¯ãŒã¯ãšåŒã°ãããã®