Skip to content

Instantly share code, notes, and snippets.

@shotahorii
Created April 12, 2019 11:37
Show Gist options
  • Save shotahorii/96f50ee851ddcdb3b3ce019ae55a9f67 to your computer and use it in GitHub Desktop.
Save shotahorii/96f50ee851ddcdb3b3ce019ae55a9f67 to your computer and use it in GitHub Desktop.
Derivative of Sigmoid Function
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Derivative of Sigmoid Function\n",
"- [シグモイド関数の微分](https://www.iwanttobeacat.com/entry/2018/07/18/195219)\n",
"\n",
"[分数関数の微分公式](https://gist.github.com/shotahorii/3ece437fefb60d978517bad8c86aea64)を使ってシグモイド関数の微分を計算する。"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"シグモイド関数は以下。\n",
"<br><br>\n",
"$$\\sigma(a) = \\frac{1}{1+exp(-a)}$$"
],
"text/plain": [
"<IPython.core.display.Latex object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%latex\n",
"シグモイド関数は以下。\n",
"<br><br>\n",
"$$\\sigma(a) = \\frac{1}{1+exp(-a)}$$"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/latex": [
"$$\\frac{d\\sigma(a)}{da} = \\frac{(1)'(1+exp(-a))-1(1+exp(-a))'}{(1+exp(-a))^2}$$<br>\n",
"$$=\\frac{0-(-exp(-a))}{(1+exp(-a))^2}$$<br>\n",
"$$=\\frac{1}{1+exp(-a)}\\frac{exp(-a)}{1+exp(-a)}$$<br>\n",
"$$=\\sigma(a)\\frac{exp(-a)}{1+exp(-a)}$$<br>\n",
"$$=\\sigma(a)\\frac{1+exp(-a)-1}{1+exp(-a)}$$<br>\n",
"$$=\\sigma(a)(1-\\frac{1}{1+exp(-a)})$$<br>\n",
"$$=\\sigma(a)(1-\\sigma(a))$$"
],
"text/plain": [
"<IPython.core.display.Latex object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%latex\n",
"$$\\frac{d\\sigma(a)}{da} = \\frac{(1)'(1+exp(-a))-1(1+exp(-a))'}{(1+exp(-a))^2}$$<br>\n",
"$$=\\frac{0-(-exp(-a))}{(1+exp(-a))^2}$$<br>\n",
"$$=\\frac{1}{1+exp(-a)}\\frac{exp(-a)}{1+exp(-a)}$$<br>\n",
"$$=\\sigma(a)\\frac{exp(-a)}{1+exp(-a)}$$<br>\n",
"$$=\\sigma(a)\\frac{1+exp(-a)-1}{1+exp(-a)}$$<br>\n",
"$$=\\sigma(a)(1-\\frac{1}{1+exp(-a)})$$<br>\n",
"$$=\\sigma(a)(1-\\sigma(a))$$"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment