{"id":7663,"date":"2019-09-28T12:32:37","date_gmt":"2019-09-28T03:32:37","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=7663"},"modified":"2020-05-28T10:14:09","modified_gmt":"2020-05-28T01:14:09","slug":"%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%a5%bc-%ec%9d%b4%ec%9a%a9%ed%95%9c-%ec%b5%9c%ec%a0%81-%ea%b0%80%ec%a4%91%ec%b9%98%ea%b0%92%ec%9d%84-%ec%96%bb%ea%b8%b0-%ec%9c%84%ed%95%9c-%ea%b2%bd%ec%82%ac%ed%95%98","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=7663","title":{"rendered":"\ucd5c\uc801 \uac00\uc911\uce58\uac12\uc744 \uc5bb\uae30 \uc704\ud55c \uacbd\uc0ac\ud558\uac15\ubc95\uc744 Python \ucf54\ub4dc\ub85c \uc774\ud574\ud558\uae30"},"content":{"rendered":"<p>\uc774 \uae00\uc740 \ud150\uc11c\ud50c\ub85c\ub098 \ud30c\uc774\ud1a0\uce58\uc640 \uac19\uc740 \uac19\uc740 \ub525\ub7ec\ub2dd \ub77c\uc774\ube0c\ub7ec\ub9ac\uc758 \uae30\ubc18\uc744 \uc774\ud574\ud558\uac70\ub098, \uc9c1\uc811 \uac1c\ubc1c\ud558\uace0\uc790 \ud560\ub54c \ucc38\uace0\ud560 \ub9cc\ud55c \uae00\ub85c \uc791\uc131\ud55c \ucf54\ub4dc\ub294 \uc774\ud574\ub97c \uc704\ud574 \ub098\uc774\ube0c\ud558\uac8c \uc791\uc131\ud588\ub2e4 . \uc544\ub798\ub294 \uc774 \uae00\uc5d0\uc11c \uc0ac\uc6a9\ud560 \ubaa8\ub378\ub85c \ub2e8\uc21c\ud654\ub97c \uc704\ud574 \uc740\ub2c9\uce35\uc740 \uc5c6\uace0 \uc785\ub825\uce35\uacfc \ucd9c\ub825\uce35\ub9cc\uc774 \uc874\uc7ac\ud55c\ub2e4.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2019\/08\/model2.png\" alt=\"\" width=\"50%\" class=\"aligncenter size-full wp-image-7671\" \/><\/p>\n<p>\uc785\ub825\uac12 x\uc640 \ud574\ub2f9 \uc785\ub825\uac12\uc5d0 \ub300\ud55c \ub77c\ubca8\uac12 t\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nx = np.array([20.1, 32.2])\r\nt = np.array([0, 0, 1])\r\n<\/pre>\n<p>\ub370\uc774\ud130\uac00 \ub2e8\uc77c \ud56d\ubaa9\uc778\ub370, \uc2e4\uc81c\ub294 \uadf8 \uac1c\uc218\uac00 \uc0c1\ub2f9\uc774 \ub9ce\uc744 \uac83\uc774\ub2e4. \uac00\uc911\uce58 W\ub294 \uc785\ub825\uac12\uc758 \ud2b9\uc131\uac1c\uc218\uac00 2\uac1c\uc774\uace0 \uce28\ub825\uac12\uc758 \ubd84\ub958\uc218\uac00 3\uac1c\uc774\ubbc0\ub85c 2&#215;3 \ud589\ub82c\uc774\uba70, \ucd08\uae30\uac12\uc740 \uc544\ub798\ucc98\ub7fc \ub09c\uc218\ub85c \uc7a1\ub294\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nW = np.random.randn(2, 3)\r\n<\/pre>\n<p>\ubaa8\ub378\uc5d0 \ub300\ud55c \uc785\ub825 \ub370\uc774\ud130\uac00 \uc815\ud574\uc84c\uc73c\ubbc0\ub85c, \ucd08\uae30\uc5d0 \ub09c\uc218\ub85c \uc815\ud55c \uac00\uc911\uce58\uac12\uc744 \ubcf4\uc815\ud558\uae30 \uc704\ud55c \ubc29\ubc95\uc778 \uacbd\uc0ac\ud558\uac15\ubc95\uc5d0 \ub300\ud55c \ud568\uc218\uc778 gradient\ub97c \ub2e4\uc74c\ucc98\ub7fc \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\ndW = gradient(x, t, W)\r\nprint(dW)\r\n<\/pre>\n<p>gradient \ud568\uc218\ub294 \uc778\uc790\ub85c \uc785\ub825\uac12\uacfc \ub77c\ubca8\uac12 \uadf8\ub9ac\uace0 \ubcf4\uc815\ud560 \uac00\uc911\uce58\uac12\uc774 \uc800\uc7a5\ub41c \ud589\ub82c\uc744 \ubc1b\uc73c\uba70, \uac00\uc911\uce58\uac12\ub4e4\uc744 \ubcf4\uc815\ud560 \uacbd\uc0ac\ub3c4(\ubbf8\ubd84\uac12)\ub97c \uac00\uc911\uce58 \ud589\ub82c\uacfc \ub3d9\uc77c\ud55c \ud06c\uae30\ub85c \ubc18\ud658\ud55c\ub2e4. \uba3c\uc800 \uc190\uc2e4\ud568\uc218 loss\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\ndef predict(input, weight):\r\n    return np.dot(input, weight)\r\n\r\ndef softmax(input):\r\n    input = input - np.max(input)\r\n    return np.exp(input) \/ np.sum(np.exp(input))\r\n\r\ndef cee(activated, label):\r\n    label = label.argmax(axis=0)\r\n    result = -np.sum(np.log(activated[label] + 1e-7))\r\n\r\n    return result    \r\n\r\ndef loss(input, label, weight):\r\n    output = predict(input, weight)\r\n    activated = softmax(output)\r\n    loss = cee(activated, label)\r\n\r\n    return loss\r\n<\/pre>\n<p>\uc190\uc2e4\ud568\uc218\ub294 \uad50\ucc28 \uc5d4\ud2b8\ub85c\ud53c \uc624\ucc28(Cross Entropy Error, CEE) \ud568\uc218\ub97c \uc0ac\uc6a9\ud588\uc73c\uba70, \ucd9c\ub825\uce35\uc5d0 \ub300\ud55c \ud65c\uc131\ud654 \ud568\uc218\ub294 Softmax\ub97c \uc0ac\uc6a9\ud55c \uac83\uc744 \uc54c \uc218 \uc788\ub2e4. \uc774\uc81c gradient \ud568\uc218\ub294 \uc544\ub798\uc640 \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\ndef gradient(input, label, weight):\r\n    h = 1e-4\r\n    grad = np.zeros_like(weight)\r\n    \r\n    it = np.nditer(weight, flags=['multi_index'])\r\n    while not it.finished:\r\n        idx = it.multi_index\r\n        v = weight[idx]\r\n\r\n        weight[idx] = v + h\r\n        fxh1 = loss(input, label, weight)\r\n        \r\n        weight[idx] = v - h \r\n        fxh2 = loss(input, label, weight)\r\n        \r\n        grad[idx] = (fxh1 - fxh2) \/ (2*h)\r\n        \r\n        weight[idx] = v\r\n\r\n        it.iternext()   \r\n        \r\n    return grad\r\n<\/pre>\n<p>\uac00\uc911\uce58\uc5d0 \ub300\ud55c W\uc758 \uac01 \uc694\uc18c\ubcc4\ub85c \ud3b8\ubbf8\ubd84\uc744 \uae30\uc6b8\uae30 \ubc29\ud5a5\uc744 \uad6c\ud558\uace0 \uc788\ub2e4. \uc774 \uae30\uc6b8\uae30 \ubc29\ud5a5\uc73c\ub85c \uc77c\uc815\ud55c \uae38\uc774\ub9cc\ud07c \uac00\uc911\uce58\uac12\uc744 \uc774\ub3d9\ud574 \uc8fc\ub294 \uac83\uc744 \ubc18\ubcf5\ud558\uba74 \ucd5c\uc18c\uc758 \uc190\uc2e4\uac12\uc744 \uac16\ub294 \uac00\uc911\uce58\ub4e4\uc758 \ubaa8\uc74c\uc744 \uc5bb\uc744 \uc218 \uc788\uac8c \ub41c\ub2e4. \uae30\uc6b8\uae30 \ubc29\ud5a5\uc744 \uad6c\ud558\uae30 \uc704\ud55c \ubc29\ubc95\uc73c\ub85c \ud3b8\ubbf8\ubd84\uc5d0 \ub300\ud55c \uc218\uce58\ud574\uc11d \uae30\ubc95\uc744 \ud65c\uc6a9\ud588\uc73c\ub098, \uc2e4\uc81c \ud150\uc11c\ud50c\ub85c\uc6b0\ub098 \ud30c\uc774\ud1a0\uce58 \ub4f1\uacfc \uac19\uc740 \uba38\uc2e0\ub7ec\ub2dd \ub77c\uc774\ube0c\ub7ec\ub9ac\uc5d0\uc11c\ub294 \uc5ed\uc804\ud30c\uae30\ubc95\uc744 \ud65c\uc6a9\ud55c\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc774 \uae00\uc740 \ud150\uc11c\ud50c\ub85c\ub098 \ud30c\uc774\ud1a0\uce58\uc640 \uac19\uc740 \uac19\uc740 \ub525\ub7ec\ub2dd \ub77c\uc774\ube0c\ub7ec\ub9ac\uc758 \uae30\ubc18\uc744 \uc774\ud574\ud558\uac70\ub098, \uc9c1\uc811 \uac1c\ubc1c\ud558\uace0\uc790 \ud560\ub54c \ucc38\uace0\ud560 \ub9cc\ud55c \uae00\ub85c \uc791\uc131\ud55c \ucf54\ub4dc\ub294 \uc774\ud574\ub97c \uc704\ud574 \ub098\uc774\ube0c\ud558\uac8c \uc791\uc131\ud588\ub2e4 . \uc544\ub798\ub294 \uc774 \uae00\uc5d0\uc11c \uc0ac\uc6a9\ud560 \ubaa8\ub378\ub85c \ub2e8\uc21c\ud654\ub97c \uc704\ud574 \uc740\ub2c9\uce35\uc740 \uc5c6\uace0 \uc785\ub825\uce35\uacfc \ucd9c\ub825\uce35\ub9cc\uc774 \uc874\uc7ac\ud55c\ub2e4. \uc785\ub825\uac12 x\uc640 \ud574\ub2f9 \uc785\ub825\uac12\uc5d0 \ub300\ud55c \ub77c\ubca8\uac12 t\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4. x = np.array([20.1, 32.2]) t = np.array([0, 0, 1]) \ub370\uc774\ud130\uac00 \ub2e8\uc77c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=7663\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\ucd5c\uc801 \uac00\uc911\uce58\uac12\uc744 \uc5bb\uae30 \uc704\ud55c \uacbd\uc0ac\ud558\uac15\ubc95\uc744 Python \ucf54\ub4dc\ub85c \uc774\ud574\ud558\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[132],"tags":[],"class_list":["post-7663","post","type-post","status-publish","format-standard","hentry","category-deep-machine-learning"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/7663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7663"}],"version-history":[{"count":14,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/7663\/revisions"}],"predecessor-version":[{"id":9377,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/7663\/revisions\/9377"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7663"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}