ãã£ã¼ãã©ã¼ãã³ã°å ¥éã®ããã®å ¥é ãã®1
ãã®ã·ãªã¼ãºã¯ä½ãªã®ã
- ãã£ã¼ãã©ã¼ãã³ã°ã¨ããã«èå³ãããã©ä½ããæãä»ãã¦ãããããããªã
- ããããæ©æ¢°å¦ç¿ã£ã¦ä½ãªã®ãããããªã
- æ°å¼èªããªã å¾®åç©åããããªã
- é«æ ¡åæ¥ãã¦ããæ°å¦ãå¦ãã äºãç¡ã
- chainerã®ãµã³ãã«ã試ãã¦ã¿ãããã©ä¸èº«ã®ã³ã¼ãã¯ãã£ã±ãããããªã
- è±èªããããªãã®ã§chainerã®ããã¥ã¡ã³ãèªããªã
ã¨ãã人åãã®chainerã使ã£ããã£ã¼ãã©ã¼ãã³ã°å ¥éããããã®å ¥éã¨ãã£ãä½ç½®ã¥ãã§ãã
æ¸ãã¦ãã人ãä¼¼ããããªã¬ãã«ã§ããå¾®åãç©åããã«ã¿è¨å·ãè¦ãã¨é çããã¾ãããã£ã¼ãã©ã¼ãã³ã°ã®æ°å¼ãä¸è¡ãç解ã§ãã¾ãããä»è±æ¤2ç´åãããè½ã¡ãããªè±èªåãã¢ã«ãããã¯ãªæ å ±å·¥å¦ã©ããã大å¦ã¯æç³»ã§ãããããã°ã©ãã§ããããã¾ããããããªäººãæ¸ãã¦ãã¾ãã
Mnist(ææ¸ãæ°åãèå¥ãã)ãµã³ãã«ãèªãã§åä½ãç解ã§ãã人ãã大å¦ã§çç³»ã«é²ãã 人ãæ å ±å·¥å¦ãå¦ãã 人ã«ã¯éå±ãªè¨äºã ã¨æãã®ã§ã¹ã«ã¼ãã¦ãã ããã
æä½épythonãèªã¿æ¸ãã§ãããã¨ãããã¦chainer(è¨äºãæ¸ããæç¹ã§ã®1.2系以åã®ãã¼ã¸ã§ã³)ãã¤ã³ã¹ãã¼ã«ããã¦ããç°å¢ããããã¨ã大åæã§ããããã®ããã®1ãã«é¢ãã¦è¨ãã°å®éã«ã³ã¼ããåãããªãã¦ãæ©æ¢°å¦ç¿ãä¸ã§ä½ããã£ã¦ããã®ããªãã¨ãªãé°å²æ°ã ãã§ãæ´ããããã«ãªãã¨æãã¾ãã
ãã®ã·ãªã¼ãºãèªç ´ããã¨ä½ãã§ããããã«ãªãã
- ãã©ãã¯ããã¯ã¹ã ã£ãæ©æ¢°å¦ç¿ãä¸ã§ä½ããã£ã¦ãã®ãä½ã¨ãªããããããã«ãªããããããªã
- 誰ããæ¸ãããµã³ãã«ãå©ç¨ããã ãã§ãªãããµã³ãã«ã®ä¸èº«ããªãã¨ãªããããããã«ãªããããããªã
- èªåã§0ããchainerã®ã³ã¼ããæ¸ããããã«ãªããããããªã
ãã®1ã§ã¯ãã¾ãæ©æ¢°å¦ç¿ã¨ã¯ãã£ããä½ãªã®ããã¨ãããã®ãã¤ããã§ãããçºã®ãã¥ã¼ããªã¢ã«çãªãã®ãããªãã¾ãã
æä½éå¿ è¦ãªç¥èããã¯ãã«ã
ãã¦ããã®åã«ã
æ©æ¢°å¦ç¿å
¨è¬ã«å¿
è¦ãªæä½éã®ç¥èã¨ãã¦ããã¯ãã«ããããã¾ãããã¯ãã«ãä½ãªã®ãããããªãã¨ä¸æ©ãå
ã«é²ããªãã¨æãã®ã§ç°¡åã«èª¬æãã¾ãã
é«æ ¡ã®æã«ç¿ã£ããã¯ãã«ã¯ãããªæãã®ã¤ã¡ã¼ã¸ã§ããã
ã§ãä»ãã使ããã¯ãã«ã¯ããã°ã©ã ã§ãã使ãé åã»Arrayã¿ãããªãã®ã ã¨æã£ã¦ãã ããã
[1,2,3,4,5]
ããã¯æ°åã5ã¤ããã®ã§5次å ã®ãã¯ãã«ã¨ããã¾ãã
ä¸ã®ä¸ã®è²ããªç©ãäºè±¡ããã¯ãã«ã§è¡¨ç¾ãããã¨ãã§ãã¾ãã
ä¾ãã°ä¸äººã®äººéããã¯ãã«åãã¾ãã
è¦ãç®ããã¯ãã«åãããªã [ èº«é· , ä½é , å¹´é½¢ ] ã®ãããªãã¯ãã«ã«ãããã¨ãã§ãã¾ãã
Aãã㯠[173 , 60 , 30] (身é·170cm , ä½é60kg , 30æ³)
Bãã㯠[154 , 46 , 20] (女æ§ã£ã½ã)
Cãã㯠[140 , 30 , 10] (åä¾ããª?)
ã¨è¡¨ç¾ã§ãã¾ãã
ãããã£ã¦ä½ã§ããã¯ãã«åãããã¨ã§ãã³ã³ãã¥ã¼ã¿ã¼ããã®å¯¾è±¡ç©ãç解ãããã¨ãå¯è½ã«ãªãã¾ãããã£ã¼ãã©ã¼ãã³ã°ã«ä»£è¡¨ãããæ©æ¢°å¦ç¿ã®ç¬¬ä¸æ©ã¯ãç¾å®ä¸çã®ç©ãäºè±¡ãã³ã³ãã¥ã¼ã¿ã¼ãèªããããã«ãã¯ãã«åãããã¨è¨ã£ã¦ãããã¨æãã¾ããæç« ã»ç»åã»åç»ãªã©ããã¯ãã«åã§ãã¾ããä½ã§ããã¯ãã«åã¯å¯è½ã§ãã
ãã¯ãã«åã®ç·´ç¿
A.ããªãã®èº«é·ä½éå¹´é½¢ããã¯ãã«åãã¦ãã ãã
B.ããªãã®ç´è¿ä¸å¹´ã®ä½éã®å¤åãä¸ã¶æåä½ã§ãã¯ãã«åãã¦ãã ãã(æ¨æ¸¬ã§æ§ãã¾ãã)
C.ããä¸é±éã®å¤©æ°ããã¯ãã«åãã¦ãã ãã
çã
Aã¯å²æ
B㯠[65 , 63 , 61 , 62 , 64 , 64 , 65 , 65 , 65 , 67 , 68 , 68]
ãã¤ã¨ããé å¼µã£ãããã©éä¸ã§ãªãã¦ã³ããå§ã¾ã£ã¦éã«ä½éãå¢ãã¦ããæ§åããããã¾ã
ãã¦Cã¯ã©ãããã°ããã§ããããã
ä¾ãã°å®éã®å¤©æ°ãæ´æ´æé¨é¨ææ´ã ã£ãã¨ãã¦ããããã©ããã¯ãã«åããã°ããã§ããããã
[æ´ , æ´ , æ , é¨ , é¨ , æ , æ´ ]
ããã§ã¯æ°å¤ãããªããããã¡ã§ãããã¯ãã«ã¯æ°å¤ã§è¡¨ç¾ãããã
ãªã®ã§æ´=0 æã=1 é¨=2ã¨é©å½ãªæ°å¤ãæ¯ããã¨ã§ãã¯ãã«åã§ãã¾ã
[0 , 0 , 1 , 2 , 2 , 1 , 0]
ãããã¯å®éã®éæ°´éãå ã«ãã¯ãã«åããæãããã¾ã
[0 , 0 , 0.1 , 1.3 , 2.5 , 0.2 , 0]
ä¸ã®ãã¯ãã«ã«æ¯ã¹ãã¨ãåãé¨ã§ã1.3ã®æ¥ããã2.5ã®æ¥ã®æ¹ãæ¿ããé¨ãéã£ãäºã表ç¾ã§ãã¦ãã¾ãã
ã¤ã¾ãCã®ãããªåé¡ã«ã¤ãã¦ã¯æ確ãªçãã¯åå¨ãã¾ãããèªåã®ãããå¦çã«å¿ãã¦ãã¯ãã«åã®æ¹æ³ãèãã¦ããå¿ è¦ãããã¾ãã
ã¡ãªã¿ã«ãã¯ãã«ã«ä½¿ããæ°å¤ã¯æ´æ°ã»å°æ°ã»ãã¤ãã¹ã¨ä½ã§ãæ§ãã¾ããã
以ä¸ã§ãã¯ãã«ã«é¢ããç°¡åãªèª¬æãçµããã¾ãã
ã¢ãã«
ãã¦ãããããä¸æ©å ã«é²ãã§ã¿ã¾ããããããããæ©æ¢°å¦ç¿ã«ãããéè¦ãªãã¢ãã«ãã¨ããæ¦å¿µãç»å ´ãã¾ãã
ã¢ãã«ã¨ã¯ãã£ããä½ãªã®ãã
ãã¯ãã«ãä¸ããã¨ããããä¸ã§ãã«ããã«ãã¨å å·¥ãã¦æ°ãããã¯ãã«ãä½ãæ©æ¢°ã ã¨(æ«å®çã«)æã£ã¦ãã ããã
ä¾ãã°ããã¯[1,2,3]ã¨ãããã¯ãã«ãä¸ããã¨ãä¸ã®æ°åããããã2åã«ãã¦è¿ãã¢ãã«ã§ãã
ã¾ãã¯ãã®ã¢ãã«ãèªåã§ä½ããããã«ãªããã¨ã
ãããåéå
ã®å½¼æ¹ã«ãããã£ã¼ãã©ã¼ãã³ã°ã¸ã®ç¬¬ä¸æ©ã§ãã
ä»æ¥ã®ç®æ¨ï¼ãã¯ãã«ã®ä¸ã®æ°åããããã2åã«ãã¦è¿ãã¢ãã«ãä½ã
ã¢ãã«ã«å¦ç¿ããã
chainerãã¤ã³ã¹ãã¼ã«ãããç°å¢ã§ä»¥ä¸ã®pythonã³ã¼ããå®è¡ãã¦ã¿ã¦ãã ããã(python2ã§ã3ã§ãåãã¯ã)
#!/usr/bin/env python # coding:utf-8 import numpy as np import chainer.functions as F from chainer import Variable, FunctionSet, optimizers #ã¢ãã«ãä½ã model = F.Linear(3,3) #ãããã¢ãã«ã«ä¸ãããã¯ãã« data = np.array([[1,2,3]] , dtype=np.float32) x = Variable(np.array(data)) #ããã§ã¢ãã«ã«ãã¯ãã«ãæãã¦ãå å·¥ããã¦ãã y = model(x) #ã¢ãã«ãå å·¥ãããã¯ãã«ã表示 print(y.data)
ãã¦ãä½ã表示ããã¾ããï¼ç§ã®ç°å¢ã§ã¯ãããªãã¾ããã
[[ 1.89820516 1.43878937 1.29263091]]
人ã«ãã£ã¦è¡¨ç¤ºããããã¯ãã«ã®å¤ã¯æ§ã ã§ãã®ã§ç§ã®ã¨éã£ã¦ãæ°ã«ããªãã§ãã ããã
ãã¦ããã®è¨äºã®ç®æ¨ã¯ããã¯ãã«ã®ä¸ã®æ°åããããã2åã«ãã¦è¿ãã¢ãã«ããä½ãäºã§ãããã¤ã¾ããããã§è¡¨ç¤ºããããã¯ãã«ã[2,4,6]ã«ãªãããã«ã¢ãã«ãä½ãããã®ã§ãããããä»ããã表示ããããã¯ãã«ã¯[2,4,6]ã¨ã¯ããé¢ãã¦ãã¾ãããï¼ãã®ã馬鹿ãªã¢ãã«ã調æãããã¨ã§è³¢ããã¦ããã¾ãããã
ã©ããã£ã¦ã¢ãã«ãè³¢ãããã®ã
æé ã¨ãã¦ã¯ä»¥ä¸ã®1~3ãä½åº¦ãä½åº¦ãç¹°ãè¿ãã¾ãã
- 1. [1,2,3]ãã¢ãã«ã«ä¸ãã¦æ£è§£ãäºæ³ããã
- 2. ã¢ãã«ãäºæ³ãããã¯ãã«ã¨ãæ£è§£ãã¯ãã«([2,4,6])ã¨ã®ãå·®ããè¨ç®ãã¦ãããåãä»è¿ãã¦ãããã¯ãã«ã¯æ£è§£ã¨ããã ãããé¢ãã¦ããï¼ãã¨æãã
- 3. ã¢ãã«ãå°ãè³¢ããªã
ãããã²ãããç¹°ãè¿ãäºã§ãå¾ã ã«ã¢ãã«ããããããã¤ã¯ä¸ã®ãã¯ãã«ãäºåããã®ã欲ãããã ãªãã¨å¦ç¿ããããã«ãªãã[2.4.6]ã«è¿ããã¯ãã«ãè¿ãããã«ãªãã¾ãã
ã¤ã¡ã¼ã¸ã¯ãããªæãã§ãã
ã¢ãã«åã«ãã¯ãã«ãä¸ãã
ã¾ã ã馬鹿ãªã¢ãã«åã¯ããå æ¸ãªãã¯ãã«ãè¿ãã¦æ¥ã
æ®´ã
ãããç¹°ãè¿ãã¾ãã
ããããã¨ã¢ãã«åãè³¢ããªã£ã¦å½¼å¥³ã®æ³ããã ãã ãã¨ããã£ã¦ãã¾ãã
â¦ä½ã¨ãªãã¤ã¡ã¼ã¸ã¯æ´ãã¾ããã§ããããï¼
ããã§ã¯å®éã«ãã£ã¦ã¿ã¾ãããã50åå¦ç¿ãããã³ã¼ãã§ãã
#!/usr/bin/env python # coding:utf-8 import numpy as np import chainer.functions as F from chainer import Variable, FunctionSet, optimizers #ã¢ãã«å®ç¾© model = F.Linear(3,3) optimizer = optimizers.SGD() optimizer.setup(model) #å¦ç¿ãããåæ° times = 50 #ä¸ãããã¯ãã« ããã[2,4,6]ã«ãªã£ã¦è¿ã£ã¦ãã¦æ¬²ãã x = Variable(np.array([[1, 2, 3]], dtype=np.float32)) #æ£è§£ãã¯ãã«ã®[2,4,6] t = Variable(np.array([[2, 4, 6]], dtype=np.float32)) #ãããã50åã«ã¼ã for i in range(0,times): optimizer.zero_grads() #ããã§ã¢ãã«ã«äºæ¸¬ããã¦ãã y = model(x) #ã¢ãã«ãåºããçãã表示 print(y.data) #ã馬鹿ãªã¢ãã«ãåºããçãã¨ãæ¬å½ã®çã([2,4,6])ãã©ã®ãããéã£ã¦ãããè¨ç®ãã loss = F.mean_squared_error(y, t) #ãã®å¤ãã¢ãã«ã«è¦ãã¦ãå ¨ç¶éããããã¼ãï¼ãã£ã¨è¿ã¥ããï¼ãã¨å¦ç¿ããã loss.backward() optimizer.update() #æåã«æ»ã£ã¦ç¹°ãè¿ã
ãããç§ã®ç°å¢ã§å®è¡ããã¨ãããªãã¾ããã
[[ 0.14060879 0.60941315 1.49593627]] [[ 0.84717733 1.89783609 3.20748067]] [[ 1.28525007 2.69665813 4.26863813]] [[ 1.55685508 3.19192839 4.92655516]] [[ 1.72525036 3.4989953 5.33446455]] [[ 1.82965517 3.68937707 5.58736801]] [[ 1.89438593 3.80741429 5.74416828]] [[ 1.93451917 3.88059664 5.84138393]] [[ 1.95940173 3.9259696 5.90165806]] [[ 1.9748292 3.95410109 5.93902826]] [[ 1.98439395 3.97154307 5.9621973 ]] [[ 1.9903245 3.98235655 5.97656202]] [[ 1.99400055 3.98906112 5.98546886]] [[ 1.99628079 3.99321771 5.99099064]] [[ 1.99769413 3.99579525 5.99441433]] [[ 1.99856997 3.99739289 5.99653673]] [[ 1.99911356 3.99838376 5.9978528 ]] [[ 1.99945033 3.99899769 5.99866819]] [[ 1.9996593 3.99937868 5.99917507]] [[ 1.99978912 3.99961495 5.99948788]] [[ 1.99986923 3.9997611 5.99968243]] [[ 1.99991894 3.99985194 5.99980354]] [[ 1.99995005 3.99990797 5.99987841]] [[ 1.99996889 3.99994326 5.99992466]] [[ 1.99998081 3.99996471 5.99995327]] [[ 1.99998832 3.99997807 5.99997091]] [[ 1.99999273 3.99998641 5.99998188]] [[ 1.99999559 3.99999166 5.99998903]] [[ 1.99999726 3.99999475 5.99999332]] [[ 1.99999809 3.99999714 5.99999523]] [[ 1.99999881 3.99999809 5.99999762]] [[ 1.99999952 3.99999857 5.99999809]] [[ 1.99999952 3.99999928 5.99999905]] [[ 1.99999952 3.99999952 5.99999952]] [[ 1.99999952 3.99999976 5.99999952]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]] [[ 1.99999952 4. 6. ]]
æå㯠0.14060879 0.60941315 1.49593627ã¨ããæ£è§£ã¨ã¯ããé¢ãããã¯ãã«ãè¿ãã¦ãã¾ãããééã£ã¦æ®´ããã度ã«å¾ã
ã«æ£è§£ã®[2,4,6]ã«è¿ã¥ãã¦ããã®ããããã§ããããã
40åç®å½ããããã¯ã»ã¼æ£è§£ãè¿ãã¦ãã¦å¤åããªããªãã¾ãããå¦ç¿ãå®äºããã®ã§ãã
ãããæ©æ¢°å¦ç¿ã¨å¼ã°ããææ³ã®åºç¤ä¸ã®åºç¤ã§ãã
1.ã¢ãã«ã«ãã¼ã¿ãä¸ãã¦
2.äºæ¸¬ããã¦
3.æ£è§£ã¨ã®å·®ãã¢ãã«ã«æãã¦å¦ç¿
4.1ã«æ»ã£ã¦ç¹°ãè¿ã
ãã£ã¼ãã©ã¼ãã³ã°ã®å ã¨ãªã£ã¦ãããã¥ã¼ã©ã«ãããã¯ã¼ã¯ã§ããã¡ãã£ã¨åã¾ã§æ©æ¢°å¦ç¿ã®ä¸»æµã ã£ãSVM(ãµãã¼ããã¯ã¿ã¼ãã·ã³)ã§ããã®åçã¯å¤ããã¾ãããã¡ãªã¿ã«ããããæ師ããå¦ç¿ãã¨å¼ã³ã¾ããæ£è§£ãã¼ã¿ãéä¸ã¢ãã«ã«ä¸ããã®ã§ãæ師ããããªãã§ããããã®éã®æ師ç¡ãå¦ç¿ã¨ãããã®ãããã¾ãã
ããã
ãã£ã¼ãã©ã¼ãã³ã°ã¨ããããã¯ãæ©æ¢°å¦ç¿ã®åºç¤ä¸ã®åºç¤ããããªããã£ãã°ããã«è§£èª¬ãã¦ã¿ã¾ãããå³å¯ãªæ°å¦ã»æ å ±å·¥å¦ãå¦ãã 人ããè¦ãã°çªã£è¾¼ã¿ã©ãããæºè¼ããããã¾ãããã大ç®ã«è¦ã¦ãã ããã
ã¢ãã«ã«ãã¼ã¿ãä¸ãã¦ã¾ãäºæ¸¬ããã¦ããã®å¾æ£è§£ãæãã¦å¦ç¿ãããããã®ç¹°ãè¿ãã§è²ããªãã¨ãèªåçã«ããªããã¢ãã«ãä½ãäºãã§ãã¾ãã
ä¾ãã°ç©ºã®åçãè¦ãã¦ããæ´ãã»ãããã»é¨ã»éªãã®ããããã®å¤©æ°ãçããããã¢ãã«ãä½ãããã¨ãã¾ããã¾ãåçããã¯ãã«åãã¾ã(ã©ããããã¯ãã¤ã解説ãã¾ã)ããã®ãã¯ãã«ãã¢ãã«ã«ä¸ãã¦æ´ãã»ãããã»é¨ã»éªã®4ã¤ããäºæ¸¬ããã¦ããã®å¾ãæ´ãã»é¨ã¨ããæ£è§£ãä¸ãã¾ãããã®ç¹°ãè¿ãã§å¤©æ°ãæ£ç¢ºã«çããããã¢ãã«ãä½ãäºãã§ãã¾ãã
ãããã ã£ãã§ããããã
ã¾ã ã¾ã ãã£ã¼ãã©ã¼ãã³ã°ã¨ã¯ã»ã©é ãå
容ã§ããããã»ãã®å°ãã ãæ©æ¢°å¦ç¿ããã£ããä½è
ãªã®ãããã£ã¦ããã ããã®ã§ã¯ãªãã§ããããã
ãã¾ããã¡ãªäººéã§ã¯ãªãã®ã§ããã®2ããã¤ã«ãªãããâ¦ã