{"id":8395,"date":"2020-03-20T20:53:08","date_gmt":"2020-03-20T11:53:08","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=8395"},"modified":"2020-05-28T09:37:21","modified_gmt":"2020-05-28T00:37:21","slug":"%ed%99%9c%ec%84%b1%ed%99%94-%ed%95%a8%ec%88%98%ec%99%80-%ec%84%a0%ed%98%95-%ed%9a%8c%ea%b7%80","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=8395","title":{"rendered":"\uc2e0\uacbd\ub9dd\uc744 \uc774\uc6a9\ud55c \ube44\uc120\ud615 \ubaa8\ub378\uc758 \ud68c\uadc0\ubd84\uc11d"},"content":{"rendered":"<p>\ub525\ub7ec\ub2dd\uc744 \uc704\ud55c \uc2e0\uacbd\ub9dd\uc740 \uae30\ubcf8\uc801\uc73c\ub85c \uc120\ud615\ud68c\uadc0\ubd84\uc11d\uc744 \uae30\ubc18\uc73c\ub85c \ud569\ub2c8\ub2e4. \uc120\ud615 \ud68c\uadc0 \ubd84\uc11d\uc774\ub77c\ub294 \uc804\uc81c \uc870\uac74\uc740 \uc544\uc8fc \ubcf5\uc7a1\ud55c \ubaa8\ub378, \uc989 \ube44\uc120\ud615\uc778 \ud615\ud0dc\uc758 \ubaa8\ub378\uc740 \ucd94\ub860\ud560 \uc218 \uc5c6\uc9c0\ub9cc, \uc2e0\uacbd\ub9dd\uc758 \uce35(Layer)\ub97c \uae4a\uac8c \uc313\uc73c\uba74\uc11c \uadf8 \uc911\uac04\uc5d0 \ube44\uc120\ud615\uc131\uc744 \ubd80\uc5ec\ud558\ub294 \ud65c\uc131\ud654 \ud568\uc218\ub97c \ub123\uc5b4\uc8fc\uac8c \ub418\uba74 \uc120\ud615\ud68c\uadc0\ubd84\uc11d\uc5d0 \uae30\ubc18\ud55c \uc2e0\uacbd\ub9dd\uc73c\ub85c\ub3c4 \uc544\uc8fc \ubcf5\uc7a1\ud55c \ube44\uc120\ud615 \ubaa8\ub378\ub3c4 \ucd94\ub860\ud560 \uc218 \uc788\ub2e4\ub294 \uac83\uc785\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, \uc544\ub798\uc640 \uac19\uc740 \ubd84\ud3ec\ub97c \uac00\uc9c0\ub294 \ub370\uc774\ud130\uc14b\uc5d0 \ub300\ud55c \ud68c\uadc0\ubd84\uc11d\ub3c4 \uac00\ub2a5\ud569\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2019\/10\/nonlinear_reg_1.png\" alt=\"\" width=\"1000\" height=\"999\" class=\"aligncenter size-full wp-image-8402\" \/><\/p>\n<p>\uc704\uc758 \ub370\uc774\ud130\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 \uacf5\uc2dd\uc5d0 \ub300\ud574\uc11c, y\uac12\uc5d0 \ud45c\uc900\ud3b8\ucc28 30\uc778 \uc815\uaddc\ubd84\ud3ec\uc758 \uc7a1\uc74c(Noise)\ub97c \ucd94\uac00\ud574 \uc0dd\uc131\ud55c \uac83\uc785\ub2c8\ub2e4.<\/p>\n<p><center><\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 26px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/ql-cache\/quicklatex.com-fb2178b28518f2389f8b382c9fb95544_l3.png\" height=\"26\" width=\"387\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#36;&#36;&#121;&#32;&#61;&#32;&#48;&#46;&#53;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#120;&#94;&#123;&#51;&#125;&#32;&#45;&#32;&#48;&#46;&#53;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#120;&#94;&#123;&#50;&#125;&#32;&#45;&#32;&#57;&#48;&#32;&#92;&#116;&#105;&#109;&#101;&#115;&#32;&#115;&#105;&#110;&#40;&#120;&#94;&#123;&#50;&#125;&#41;&#32;&#43;&#32;&#49;&#32;&#36;&#36;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p><\/center><\/p>\n<p>\uc774\uc81c \uc704\uc758 \ub370\uc774\ud130\uc14b\uc744 \uc774\uc6a9\ud574 \ub525\ub7ec\ub2dd \ud559\uc2b5\uc744 \ud1b5\ud574 \ube44\uc120\ud615 \ubaa8\ub378\uc5d0 \ub300\ud55c \ucd94\ub860\uc5d0 \ub300\ud55c \ucf54\ub4dc\ub97c \uc815\ub9ac\ud558\uaca0\uc2b5\ub2c8\ub2e4. \ucf54\ub4dc\ub294 \ud30c\uc774\uc120\uc73c\ub85c, \uadf8\ub9ac\uace0 \ub525\ub7ec\ub2dd \ub77c\uc774\ube0c\ub7ec\ub9ac\ub294 \ud30c\uc774\ud1a0\uce58\ub97c \uc0ac\uc6a9\ud588\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uba3c\uc800 \ud544\uc694\ud55c \ud328\ud0a4\uc9c0\ub97c \uc784\ud3ec\ud2b8\ud569\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nimport torch\r\nimport torch.nn as nn\r\nimport torch.optim as optim\r\nimport torch.nn.init as init\r\nimport matplotlib.pyplot as plt\r\n<\/pre>\n<p>\ud559\uc2b5\uc744 \uc704\ud574 \ub370\uc774\ud130\uac00 \ud544\uc694\ud55c\ub370, \uc55e\uc11c \uc5b8\uae09\ud55c \uacf5\uc2dd\uc744 \ud65c\uc6a9\ud558\uc5ec \ucd1d 5000\uac1c\uc758 (x, y) \uac12\uc758 \ub370\uc774\ud130\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4. \ubb3c\ub860 y \uac12\uc5d0\ub294 \ub9c8\ucc2c\uac00\uc9c0\ub85c \uc55e\uc11c \uc5b8\uae09\ud55c \ud45c\uc900\ud3b8\ucc28\uac00 30\uc778 \uc815\uaddc\ubd84\ud3ec\ub85c \uc0dd\uc131\ub41c \uc7a1\uc74c\uc744 \ubc18\uc601\ud569\ub2c8\ub2e4. \uc544\ub798\ub294 \uc774\uc5d0 \ub300\ud55c \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nnum_data = 5000\r\nnoise = init.normal_(torch.FloatTensor(num_data,1), std=30)\r\nx = init.uniform_(torch.Tensor(num_data,1),-10,10)\r\n\r\ndef func(x): return 0.5*(x**3) - 0.5*(x**2) - torch.sin(2*x)*90 + 1 \r\ny_noise = func(x) + noise\r\n<\/pre>\n<p>\uc2e0\uacbd\ub9dd \ubaa8\ub378\uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4. \uc2e0\uacbd\ub9dd \ubaa8\ub378\uc5d0 \ub300\ud55c \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nmodel = nn.Sequential(\r\n    nn.Linear(1,5),\r\n    nn.LeakyReLU(0.2),\r\n    nn.Linear(5,10),\r\n    nn.LeakyReLU(0.2),\r\n    nn.Linear(10,10),\r\n    nn.LeakyReLU(0.2),    \r\n    nn.Linear(10,10),\r\n    nn.LeakyReLU(0.2),        \r\n    nn.Linear(10,5),\r\n    nn.LeakyReLU(0.2),          \r\n    nn.Linear(5,1),\r\n)\r\n<\/pre>\n<p>\uc704\uc758 \uc2e0\uacbd\ub9dd\uc744 \ub3c4\uc2dd\ud654\ud558\uba74 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2019\/10\/nonlinear_reg_4.png\" alt=\"\" width=\"2075\" height=\"127\" class=\"aligncenter size-full wp-image-8405\" \/><\/p>\n<p>\ud65c\uc131\ud654 \ud568\uc218\ub85c Leaky ReLU\ub97c \uc0ac\uc6a9\ud55c \uc774\uc720\ub294, Sigmoid\uc758 \uacbd\uc6b0 \uae30\uc6b8\uae30 \uc18c\uc2e4\uc774 \ubc1c\uc0dd\ud558\uc5ec \ud559\uc2b5\uc774 \uc798\uc774\ub8e8\uc5b4\uc9c0\uc9c0 \uc54a\uace0 \uc77c\ubc18 ReLU\ub97c \uc0ac\uc6a9\ud560 \uacbd\uc6b0 \ud559\uc2b5 \ub300\uc0c1\uc774 \ub418\ub294 \uac00\uc911\uce58\uc640 \ud3b8\ud5a5\uc774 \uc74c\uc218\uac00 \ub420 \uacbd\uc6b0\uc5d0 \uc785\ub825\uac12\uae4c\uc9c0 \uc74c\uc218\uac00 \ub418\uba74 \ucd5c\uc885 \ud65c\uc131\ud654 \uac12\uc774 \ud56d\uc0c1 0\uc774 \ub418\uc5b4 \uc774 \uac12\uc774 \ub274\ub7f0\uc5d0 \uc804\ub2ec\ub418\uace0, \uc804\ub2ec \ubc1b\uc740 \ub274\ub7f0\uc774 \uc81c \uc5ed\ud65c\uc744 \ud558\uc9c0 \ubabb\ud558\ub294 \ud604\uc0c1(\ubb38\ud5cc\uc5d0\uc11c\ub294 Dying Neuron\uc774\ub77c\uace0 \ud568)\uc774 \ubc1c\uc0dd\ud558\uae30 \ub54c\ubb38\uc785\ub2c8\ub2e4 Leaky ReLU\ub294 \uae30\uc6b8\uae30 \uc18c\uc2e4 \ubb38\uc81c\uc640 \uc785\ub825\uac12\uc774 \uc74c\uc218\uc77c\ub54c\uc5d0\ub3c4 \uc77c\ubc18 ReLU\ucc98\ub7fc 0\uc774 \uc544\ub2cc \uac00\uc911\uce58(\uc704\uc5d0\uc11c\ub294 0.2)\uac00 \ubc18\uc601\ub41c \uac12\uc774 \ud65c\uc131\uac12\uc73c\ub85c \uacb0\uc815\ub418\uc5b4 Dying Neuron \ud604\uc0c1\uc744 \ub9c9\uc544\uc90d\ub2c8\ub2e4. <\/p>\n<p>\ub2e4\uc74c\uc740 \ud559\uc2b5\uc5d0 \ub300\ud55c \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\ngpu = torch.device('cuda')\r\nloss_func = nn.L1Loss().to(gpu)\r\noptimizer = torch.optim.Adam(model.parameters(), lr=0.002)\r\n\r\nmodel = model.to(gpu)\r\nx = x.to(gpu)\r\ny_noise = y_noise.to(gpu)\r\n\r\nnum_epoch = 20000\r\nloss_array = []\r\nfor epoch in range(num_epoch):\r\n    optimizer.zero_grad()\r\n    output = model(x)\r\n    \r\n    loss = loss_func(output,y_noise)\r\n    loss.backward()\r\n    optimizer.step()\r\n    \r\n    loss_array.append(loss)\r\n\r\n    if epoch % 100 == 0:\r\n        print('epoch:', epoch, ' loss:', loss.item())\r\n<\/pre>\n<p>\uc190\uc2e4\uac12\uc740 \ub9e4\uc6b0 \ub2e8\uc21c\ud55c L1 \uc190\uc2e4\uc744 \uc0ac\uc6a9\ub294\ub370, \uc704\uc758 \ud559\uc2b5\uc744 \uc704\ud55c \ub370\uc774\ud130\uc14b\uc758 \uacbd\uc6b0 \uc624\ucc28\uac12\uc758 \uc808\ub300\uac12\uc774 L1 \uac12\uc774\uace0 \uc624\ucc28\uac12\uc5d0 \ub300\ud574 \uc190\uc2e4\uac12\uc774 \ube44\ub840\ud558\ubbc0\ub85c L1 \uc190\uc2e4\uc740 \uc801\ub2f9\ud558\uace0 \ud559\uc2b5 \uc18d\ub3c4\uac00 \ube60\ub985\ub2c8\ub2e4. \uadf8\ub9ac\uace0 \uac00\uc911\uce58\uc5d0 \ub300\ud55c \ucd5c\uc801\ud654 \ubc29\ubc95\uc740 Adam\uc744 \uc0ac\uc6a9\ud588\uc2b5\ub2c8\ub2e4. \uc77c\ubc18 SGD \ubc29\uc2dd\uc740 \uadf8 \ubc29\uc2dd\uc774 \ub9e4\uc6b0 \ub2e8\uc21c\ud574\uc11c \uc880\ucc98\ub7fc \ud559\uc2b5\uc774 \ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uc774\uc81c \ud559\uc2b5 \ub3d9\uc548 \uc190\uc2e4\uac12\uc758 \ucd94\uc774\uc640 \ucd94\ub860\ub41c \uc2e0\uacbd\ub9dd\uc758 \ubaa8\ub378\uc5d0 \ub300\ud55c \uacb0\uacfc\ub97c \uadf8\ub798\ud504\ub85c \ub098\ud0c0\ub0b4\uae30 \uc704\ud55c \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nplt.plot(loss_array)\r\nplt.show()\r\n\r\nplt.figure(figsize=(10,10))\r\n\r\nx = x.cpu().detach().numpy()\r\ny_noise = y_noise.cpu().detach().numpy()\r\noutput = output.cpu().detach().numpy()\r\n\r\nplt.scatter(x, y_noise, s=1, c=\"gray\")\r\nplt.scatter(x, output, s=1, c=\"red\")\r\n\r\nplt.show()\r\n<\/pre>\n<p>\uc704 \ucf54\ub4dc\uc5d0\uc11c \uc190\uc2e4\uc5d0 \ub300\ud55c \uadf8\ub798\ud504 \uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2019\/10\/nonlinear_reg_2.png\" alt=\"\" width=\"1166\" height=\"909\" class=\"aligncenter size-full wp-image-8406\" \/><\/p>\n<p>\uc190\uc2e4\uac12\uc774 \ub9e4 \uc5d0\ud3ed\ub9c8\ub2e4 \uac10\uc18c\ud558\ub294 \uac83\uc744 \ubcf4\uba74 \ud559\uc2b5\uc774 \uc81c\ub300\ub85c \uc774\ub8e8\uc5b4\uc9c0\uace0 \uc788\ub2e4\ub294 \uac83\uc744 \uc54c \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub9ac\uace0 \uac00\uc7a5 \uc911\uc694\ud55c \uadf8\ub798\ud504\uc778, \uc2e0\uacbd\ub9dd \ud559\uc2b5\uc758 \ucd94\ub860 \uacb0\uacfc\uc5d0 \ub300\ud55c \uadf8\ub798\ud504\uc785\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2019\/10\/nonlinear_reg_3.png\" alt=\"\" width=\"1000\" height=\"999\" class=\"aligncenter size-full wp-image-8407\" \/><\/p>\n<p>\ud68c\uc0c9 \uc9c0\ud45c\ub294 \ud559\uc2b5 \ub370\uc774\ud130\uc774\uace0 \ube68\uac04\uc0c9 \uc9c0\ud45c\uac00 \ud559\uc2b5\ub41c \ubaa8\ub378\uc774 \ucd94\ub860\ud55c \uacb0\uacfc\uc785\ub2c8\ub2e4. \ub370\uc774\ud14c\uc5d0 \ub9e4\uc6b0 \uadfc\uc811\ud55c \ucd94\ub860 \uacb0\uacfc\ub97c \ub098\ud0c0\ub0b4\uace0 \uc788\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub798\ud504\uac00 \uace1\uc120\ucc98\ub7fc \ubcf4\uc774\uc9c0\ub9cc \uc0ac\uc2e4\uc740 \uc9c1\uc120\uc73c\ub85c \uad6c\uc131\ub41c \uadf8\ub798\ud504\uc785\ub2c8\ub2e4. \uc774\ub294 \uc55e\uc11c \uc5b8\uae09\ud588\ub4ef\uc774 \uc2e0\uacbd\ub9dd\uc774 \uc120\ud615\ud68c\uadc0\uc5d0 \uae30\ubc18\ud558\uace0 \uc788\uae30 \ub54c\ubb38\uc785\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ub525\ub7ec\ub2dd\uc744 \uc704\ud55c \uc2e0\uacbd\ub9dd\uc740 \uae30\ubcf8\uc801\uc73c\ub85c \uc120\ud615\ud68c\uadc0\ubd84\uc11d\uc744 \uae30\ubc18\uc73c\ub85c \ud569\ub2c8\ub2e4. \uc120\ud615 \ud68c\uadc0 \ubd84\uc11d\uc774\ub77c\ub294 \uc804\uc81c \uc870\uac74\uc740 \uc544\uc8fc \ubcf5\uc7a1\ud55c \ubaa8\ub378, \uc989 \ube44\uc120\ud615\uc778 \ud615\ud0dc\uc758 \ubaa8\ub378\uc740 \ucd94\ub860\ud560 \uc218 \uc5c6\uc9c0\ub9cc, \uc2e0\uacbd\ub9dd\uc758 \uce35(Layer)\ub97c \uae4a\uac8c \uc313\uc73c\uba74\uc11c \uadf8 \uc911\uac04\uc5d0 \ube44\uc120\ud615\uc131\uc744 \ubd80\uc5ec\ud558\ub294 \ud65c\uc131\ud654 \ud568\uc218\ub97c \ub123\uc5b4\uc8fc\uac8c \ub418\uba74 \uc120\ud615\ud68c\uadc0\ubd84\uc11d\uc5d0 \uae30\ubc18\ud55c \uc2e0\uacbd\ub9dd\uc73c\ub85c\ub3c4 \uc544\uc8fc \ubcf5\uc7a1\ud55c \ube44\uc120\ud615 \ubaa8\ub378\ub3c4 \ucd94\ub860\ud560 \uc218 \uc788\ub2e4\ub294 \uac83\uc785\ub2c8\ub2e4. \uc608\ub97c \ub4e4\uc5b4, \uc544\ub798\uc640 \uac19\uc740 \ubd84\ud3ec\ub97c \uac00\uc9c0\ub294 \ub370\uc774\ud130\uc14b\uc5d0 \ub300\ud55c \ud68c\uadc0\ubd84\uc11d\ub3c4 \uac00\ub2a5\ud569\ub2c8\ub2e4. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=8395\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\uc2e0\uacbd\ub9dd\uc744 \uc774\uc6a9\ud55c \ube44\uc120\ud615 \ubaa8\ub378\uc758 \ud68c\uadc0\ubd84\uc11d&#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":[131,132],"tags":[],"class_list":["post-8395","post","type-post","status-publish","format-standard","hentry","category-python","category-deep-machine-learning"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8395","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=8395"}],"version-history":[{"count":12,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8395\/revisions"}],"predecessor-version":[{"id":9326,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8395\/revisions\/9326"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8395"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}