Merge branch 'master' of /Users/ageron/dev/py/ml/ml-notebooks1
commit
40ac161744
|
@ -160,7 +160,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def logit(z):\n",
|
||||
"def sigmoid(z):\n",
|
||||
" return 1 / (1 + np.exp(-z))\n",
|
||||
"\n",
|
||||
"def relu(z):\n",
|
||||
|
@ -181,8 +181,8 @@
|
|||
"plt.figure(figsize=(11,4))\n",
|
||||
"\n",
|
||||
"plt.subplot(121)\n",
|
||||
"plt.plot(z, np.sign(z), \"r-\", linewidth=2, label=\"Step\")\n",
|
||||
"plt.plot(z, logit(z), \"g--\", linewidth=2, label=\"Logit\")\n",
|
||||
"plt.plot(z, np.sign(z), \"r-\", linewidth=1, label=\"Step\")\n",
|
||||
"plt.plot(z, sigmoid(z), \"g--\", linewidth=2, label=\"Sigmoid\")\n",
|
||||
"plt.plot(z, np.tanh(z), \"b-\", linewidth=2, label=\"Tanh\")\n",
|
||||
"plt.plot(z, relu(z), \"m-.\", linewidth=2, label=\"ReLU\")\n",
|
||||
"plt.grid(True)\n",
|
||||
|
@ -191,10 +191,10 @@
|
|||
"plt.axis([-5, 5, -1.2, 1.2])\n",
|
||||
"\n",
|
||||
"plt.subplot(122)\n",
|
||||
"plt.plot(z, derivative(np.sign, z), \"r-\", linewidth=2, label=\"Step\")\n",
|
||||
"plt.plot(z, derivative(np.sign, z), \"r-\", linewidth=1, label=\"Step\")\n",
|
||||
"plt.plot(0, 0, \"ro\", markersize=5)\n",
|
||||
"plt.plot(0, 0, \"rx\", markersize=10)\n",
|
||||
"plt.plot(z, derivative(logit, z), \"g--\", linewidth=2, label=\"Logit\")\n",
|
||||
"plt.plot(z, derivative(sigmoid, z), \"g--\", linewidth=2, label=\"Sigmoid\")\n",
|
||||
"plt.plot(z, derivative(np.tanh, z), \"b-\", linewidth=2, label=\"Tanh\")\n",
|
||||
"plt.plot(z, derivative(relu, z), \"m-.\", linewidth=2, label=\"ReLU\")\n",
|
||||
"plt.grid(True)\n",
|
||||
|
@ -215,9 +215,6 @@
|
|||
"def heaviside(z):\n",
|
||||
" return (z >= 0).astype(z.dtype)\n",
|
||||
"\n",
|
||||
"def sigmoid(z):\n",
|
||||
" return 1/(1+np.exp(-z))\n",
|
||||
"\n",
|
||||
"def mlp_xor(x1, x2, activation=heaviside):\n",
|
||||
" return activation(-activation(x1 + x2 - 1.5) + activation(x1 + x2 - 0.5) - 0.5)"
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue