{"id":2623,"date":"2021-02-01T23:51:41","date_gmt":"2021-02-01T14:51:41","guid":{"rendered":"https:\/\/obenkyolab.com\/?p=2623"},"modified":"2022-01-29T00:37:53","modified_gmt":"2022-01-28T15:37:53","slug":"%e3%80%90deeplearning%e3%80%91%e6%b4%bb%e6%80%a7%e5%8c%96%e9%96%a2%e6%95%b0%e3%82%92python%e3%81%a7%e6%8f%8f%e7%94%bb%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/obenkyolab.com\/?p=2623","title":{"rendered":"\u3010Python\u3011\u6d3b\u6027\u5316\u95a2\u6570\u3092\u63cf\u753b\u3059\u308b"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#%E6%A6%82%E8%A6%81\" >\u6982\u8981<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA\" >\u4f7f\u7528\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#%E3%82%B9%E3%83%86%E3%83%83%E3%83%97%E9%96%A2%E6%95%B0\" >\u30b9\u30c6\u30c3\u30d7\u95a2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#%E3%82%B7%E3%82%B0%E3%83%A2%E3%82%A4%E3%83%89%E9%96%A2%E6%95%B0\" >\u30b7\u30b0\u30e2\u30a4\u30c9\u95a2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#tahn%E9%96%A2%E6%95%B0\" >tahn\u95a2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#ReLu%E9%96%A2%E6%95%B0\" >ReLu\u95a2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#Leaky_ReLu%E9%96%A2%E6%95%B0\" >Leaky ReLu\u95a2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#%E3%81%BE%E3%81%A8%E3%82%81\" >\u307e\u3068\u3081<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/obenkyolab.com\/?p=2623\/#%E3%82%B3%E3%83%BC%E3%83%89%E5%85%A8%E4%BD%93\" >\u30b3\u30fc\u30c9\u5168\u4f53<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"\u6982\u8981\"><span class=\"ez-toc-section\" id=\"%E6%A6%82%E8%A6%81\"><\/span>\u6982\u8981<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Deep Learning\u306e\u30cb\u30e5\u30fc\u30ed\u30f3\u3067\u4f7f\u7528\u3059\u308b\u6d3b\u6027\u5316\u95a2\u6570\u3068\u3057\u3066\u30b9\u30c6\u30c3\u30d7\u95a2\u6570\u3001\u30b7\u30b0\u30e2\u30a4\u30c9\u95a2\u6570\u3001ReLu\u95a2\u6570\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7d20\u4eba\u306a\u306e\u3067\u3001\u3042\u307e\u308a\u8a73\u3057\u304f\u306f\u306a\u3044\u3067\u3059\u304c\u3001\u3088\u304f\u4f7f\u308f\u308c\u308b\u306e\u306fReLu\u95a2\u6570\u3089\u3057\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u3053\u306e\u6d3b\u6027\u5316\u95a2\u6570\u3068\u305d\u306e\u5fae\u5206\u3092python\u3067\u63cf\u753b\u3057\u3066\u5b9f\u969b\u306b\u3069\u3093\u306a\u7279\u6027\u304c\u3042\u308b\u306e\u304b\u53ef\u8996\u5316\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4f7f\u7528\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\"><span class=\"ez-toc-section\" id=\"%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA\"><\/span>\u4f7f\u7528\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>numpy<\/li><li>matplotlib.pyplot<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u30b9\u30c6\u30c3\u30d7\u95a2\u6570\"><span class=\"ez-toc-section\" id=\"%E3%82%B9%E3%83%86%E3%83%83%E3%83%97%E9%96%A2%E6%95%B0\"><\/span> \u30b9\u30c6\u30c3\u30d7\u95a2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"step_func\" data-lang=\"Python\"><code>import numpy as np\nimport matplotlib.pyplot as plt\n\n#\u95a2\u6570\u5b9a\u7fa9\ndef step(x):\n    return 1.0*(x&gt;=0)\n\n#\u30b9\u30c6\u30c3\u30d7\u95a2\u6570\u5165\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\nx = np.linspace(-1,1,500)\ny = step(x)\n\n#\u63cf\u753b\nfig = plt.figure()\nax = fig.add_subplot(111)\nax.plot(x,y)\nplt.show()<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"354\" height=\"226\" src=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-4.png\" alt=\"\" class=\"wp-image-2650\" srcset=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-4.png 354w, https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-4-300x192.png 300w\" sizes=\"auto, (max-width: 354px) 100vw, 354px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u30b7\u30b0\u30e2\u30a4\u30c9\u95a2\u6570\"><span class=\"ez-toc-section\" id=\"%E3%82%B7%E3%82%B0%E3%83%A2%E3%82%A4%E3%83%89%E9%96%A2%E6%95%B0\"><\/span>\u30b7\u30b0\u30e2\u30a4\u30c9\u95a2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"sigmoid_func\" data-lang=\"Python\"><code>#sigmoid\u95a2\u6570\ndef sigmoid(x):\n    return 1\/(1+np.exp(-x))\n\n#sigmoid\u306e\u5c0e\u95a2\u6570\ndef derivative_sigmoid(x):\n    return sigmoid(x)*(1-sigmoid(x))\n\n#sigmoid\u95a2\u6570\u5165\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\nx = np.linspace(-5,5)\ny = sigmoid(x)\n\n#\u63cf\u753b\nfig = plt.figure()\nax = fig.add_subplot(211)\nax.plot(x,y)\nplt.title(&#39;sigmoid&#39;)\n\n#sigmoid\u306e\u5c0e\u95a2\u6570\u306e\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\ny = derivative_sigmoid(x)\n\n#\u63cf\u753b\nax = fig.add_subplot(212)\nax.plot(x,y)\nplt.title(&#39;derivative sigmoid&#39;)\n\n#\u30b0\u30e9\u30d5\u9593\u9694\u8abf\u6574\nplt.subplots_adjust(wspace=0.4, hspace=0.6)\nplt.show()<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"246\" src=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-5.png\" alt=\"\" class=\"wp-image-2651\" srcset=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-5.png 352w, https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-5-300x210.png 300w\" sizes=\"auto, (max-width: 352px) 100vw, 352px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tahn\u95a2\u6570\"><span class=\"ez-toc-section\" id=\"tahn%E9%96%A2%E6%95%B0\"><\/span>tahn\u95a2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"tahn_func\" data-lang=\"Python\"><code>#tanh\u95a2\u6570\u306e\u5165\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\nx = np.linspace(-5,5)\ny = np.tanh(x)\n\n#\u63cf\u753b\nfig = plt.figure()\nax = fig.add_subplot(211)\nax.plot(x,y)\nplt.title(&#39;tanh&#39;)\n\n#tanh\u306e\u5c0e\u95a2\u6570\ndef derivative_tanh(x):\n    return 4\/((np.exp(x)+np.exp(-x))**2)\n\n#tanh\u5c0e\u95a2\u6570\u306e\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\ny = derivative_tanh(x)\n\n#\u63cf\u753b\nfig = plt.figure()\nax = fig.add_subplot(212)\nax.plot(x,y)\nplt.title(&#39;derivative tanh&#39;)\n\nplt.show()<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"358\" height=\"273\" src=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-6.png\" alt=\"\" class=\"wp-image-2652\" srcset=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-6.png 358w, https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-6-300x229.png 300w\" sizes=\"auto, (max-width: 358px) 100vw, 358px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"relu\u95a2\u6570\"><span class=\"ez-toc-section\" id=\"ReLu%E9%96%A2%E6%95%B0\"><\/span>ReLu\u95a2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"relu_func\" data-lang=\"Python\"><code>#ReLu\u95a2\u6570\u5b9a\u7fa9\ndef relu(x):\n    return x*(x&gt;=0)\n\n#ReLu\u95a2\u6570\u306e\u5165\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\nx = np.linspace(-5,5,500)\ny = relu(x)\n\n#\u63cf\u753b\nfig = plt.figure()\nax = fig.add_subplot(211)\nax.plot(x,y)\nplt.title(&#39;ReLu&#39;)\n\n#ReLu\u306e\u5c0e\u95a2\u6570\u5b9a\u7fa9\ndef derivative_relu(x):\n    return 1*(x&gt;=0)\n\n#ReLu\u5c0e\u95a2\u6570\u306e\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\ny = derivative_relu(x)\n\n#\u63cf\u753b\nfig = plt.figure()\nax = fig.add_subplot(212)\nax.plot(x,y)\nplt.title(&#39;derivative ReLu&#39;)\n\nplt.show()<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"345\" height=\"279\" src=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-8.png\" alt=\"\" class=\"wp-image-2655\" srcset=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-8.png 345w, https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-8-300x243.png 300w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"leaky-relu\u95a2\u6570\"><span class=\"ez-toc-section\" id=\"Leaky_ReLu%E9%96%A2%E6%95%B0\"><\/span>Leaky ReLu\u95a2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-python\" data-file=\"leaky_relu_func\" data-lang=\"Python\"><code>#Leaky ReLu\u95a2\u6570\u306e\u5b9a\u7fa9\ndef leaky_relu(x):\n    return np.where(x &lt; 0,0.01*x,x)\n\n#Leaky ReLu\u95a2\u6570\u306e\u5165\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\nx = np.linspace(-5,5,500)\ny = leaky_relu(x)\n\n#\u63cf\u753b\nfig = plt.figure()\nax = fig.add_subplot(111)\nax.plot(x,y)\nplt.title(&#39;Leaky ReLu&#39;)\n\n#Leaky ReLu\u5c0e\u95a2\u6570\u306e\u5b9a\u7fa9\ndef derivative_leaky_relu(x):\n    return np.where(x &lt; 0,0.01,1)\n\n#\u5c0e\u95a2\u6570\u306e\u51fa\u529b\u30c7\u30fc\u30bf\u4f5c\u6210\ny = derivative_leaky_relu(x)\n\n#\u63cf\u753b\nfig = plt.figure()\nax = fig.add_subplot(111)\nax.plot(x,y)\nplt.title(&#39;derivative Leaky ReLu&#39;)\n\nplt.show()<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"479\" src=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-7.png\" alt=\"\" class=\"wp-image-2654\" srcset=\"https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-7.png 352w, https:\/\/obenkyolab.com\/wp-content\/uploads\/2021\/02\/image-7-220x300.png 220w\" sizes=\"auto, (max-width: 352px) 100vw, 352px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u307e\u3068\u3081\"><span class=\"ez-toc-section\" id=\"%E3%81%BE%E3%81%A8%E3%82%81\"><\/span>\u307e\u3068\u3081<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u30b7\u30b0\u30e2\u30a4\u30c9\u95a2\u6570\u306f\u5c0e\u95a2\u6570\u306e\u5024\u304c\u6700\u5927\u3067\u30820.25\u7a0b\u5ea6\u306e\u305f\u3081\u3001\u8aa4\u5dee\u9006\u4f1d\u64ad\u3057\u305f\u3068\u304d\u306b\u52fe\u914d\u6d88\u5931\u304c\u8d77\u304d\u3084\u3059\u3044\u3002<br>\u305d\u308c\u306b\u5bfe\u3057\u3066tanh\u3084ReLu\u306f\u6700\u59271.0\u306a\u306e\u3067sigmoid\u3088\u308a\u4f7f\u3044\u3084\u3059\u3044\u3089\u3057\u3044\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u30b3\u30fc\u30c9\u5168\u4f53\"><span class=\"ez-toc-section\" id=\"%E3%82%B3%E3%83%BC%E3%83%89%E5%85%A8%E4%BD%93\"><\/span>\u30b3\u30fc\u30c9\u5168\u4f53<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<script src=\"https:\/\/gist.github.com\/kolnhouse\/6569258467c26ef4abb35c7179e2736f.js\"><\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 Deep Learning\u306e\u30cb\u30e5\u30fc\u30ed\u30f3\u3067\u4f7f\u7528\u3059\u308b\u6d3b\u6027\u5316\u95a2\u6570\u3068\u3057&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1218,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/obenkyolab.com\/?p=2623","footnotes":""},"categories":[7,53],"tags":[],"class_list":["post-2623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-53","ja"],"_links":{"self":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/2623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2623"}],"version-history":[{"count":15,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/2623\/revisions"}],"predecessor-version":[{"id":4738,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/2623\/revisions\/4738"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/media\/1218"}],"wp:attachment":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}