Skip to content

Instantly share code, notes, and snippets.

@taka-wang
Last active March 23, 2020 10:24
Show Gist options
  • Save taka-wang/bd9b22db366333a153a6d1340e8dda4c to your computer and use it in GitHub Desktop.
Save taka-wang/bd9b22db366333a153a6d1340e8dda4c to your computer and use it in GitHub Desktop.
ai basic1 snippets
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Activation functions"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"def tanh(x):\n",
" return (np.exp(x)-np.exp(-x))/(np.exp(x)+np.exp(-x))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"def tanhDerivative(x):\n",
" return 1.0 - tanh(x)**2"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"def sigmoid(x):\n",
" return 1. / (1. + np.exp(-x))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# Derivative of the Sigmoid activation function\n",
"def SigmoidDerivative(x):\n",
" return sigmoid(x) * (1 - sigmoid(x))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"def relu(x):\n",
" return np.maximum(0,x)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# Derivative of the RELU activation function\n",
"def reluDerivative(x):\n",
" return np.where(x <= 0, 0, 1)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"def leaky(x):\n",
" return np.array([0.07*item if item<0 else item for item in x ]) "
]
},
{
"cell_type": "code",
"execution_count": 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5i/A2ovKFonUw+/Nk6FpA9ZGkGuwf8PRg1hfWw3Wrltft3n90fIzrBdbENiFdSqMSHgUSMMa0wVrw63dta4AFmKFzhtY48gX27BeP9ZQ11Ks8eknsXY5tNPzwAysb6J7sL5l/a63PzgJ5wDz+L/dDMEaNrRzD7MhWGfVdWN1MF8gsrtNRtIgrF49WNn5R6y9aez2baxvXKlYOwZca9eKdWoFERGHcMqQjoiI4ynwRUQcQoEvIuIQCnwREYdQ4IuIOIQCX0TEIRT4IiIO8b+CAsH0J4gyvAAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"ax = fig.add_subplot(111)\n",
"\n",
"# generate data\n",
"x = np.arange(-6.1, 6.1, 0.1)\n",
"y = sigmoid(x)\n",
"ax.plot(x, y)\n",
"plt.xticks(np.arange(-6.0, 7.0, 1))\n",
"plt.yticks(np.arange(-0.2, 1.2, 0.2))\n",
"\n",
"# red line\n",
"plt.axvline(x=0, label='line at x = {}'.format(0), c='r')\n",
"\n",
"#''' change style\n",
"# ref: https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis\n",
"ax.spines['bottom'].set_color('#dddddd')\n",
"ax.spines['top'].set_color('#dddddd') \n",
"ax.spines['right'].set_color('#dddddd')\n",
"ax.spines['left'].set_color('#dddddd')\n",
"ax.tick_params(axis='x', colors='white')\n",
"ax.tick_params(axis='y', colors='white')\n",
"ax.yaxis.label.set_color('white')\n",
"ax.xaxis.label.set_color('white')\n",
"#'''\n",
"\n",
"# export\n",
"plt.grid()\n",
"plt.savefig('sigmoid.png', dpi=300, transparent=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig = plt.figure()\n",
"ax = fig.add_subplot(111)\n",
"\n",
"# generate data\n",
"x = np.arange(-6.1, 6.1, 0.1)\n",
"#y = sigmoid(x)\n",
"y = SigmoidDerivative(x)\n",
"ax.plot(x, y)\n",
"plt.xticks(np.arange(-6.0, 7.0, 1))\n",
"plt.yticks(np.arange(-0.2, 1.2, 0.2))\n",
"\n",
"# red line\n",
"plt.axvline(x=0, label='line at x = {}'.format(0), c='r')\n",
"\n",
"#''' change style\n",
"# ref: https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis\n",
"ax.spines['bottom'].set_color('#dddddd')\n",
"ax.spines['top'].set_color('#dddddd') \n",
"ax.spines['right'].set_color('#dddddd')\n",
"ax.spines['left'].set_color('#dddddd')\n",
"ax.tick_params(axis='x', colors='white')\n",
"ax.tick_params(axis='y', colors='white')\n",
"ax.yaxis.label.set_color('white')\n",
"ax.xaxis.label.set_color('white')\n",
"#'''\n",
"\n",
"# export\n",
"plt.grid()\n",
"plt.savefig('derivative_sigmoid.png', dpi=300, transparent=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig = plt.figure()\n",
"ax = fig.add_subplot(111)\n",
"\n",
"# generate data\n",
"x = np.arange(-6.1, 6.1, 0.1)\n",
"y = tanh(x)\n",
"ax.plot(x, y)\n",
"plt.xticks(np.arange(-6.0, 7.0, 1))\n",
"plt.yticks(np.arange(-1.2, 1.2, 0.4))\n",
"\n",
"# red line\n",
"plt.axvline(x=0, label='line at x = {}'.format(0), c='r')\n",
"\n",
"#''' change style\n",
"# ref: https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis\n",
"ax.spines['bottom'].set_color('#dddddd')\n",
"ax.spines['top'].set_color('#dddddd') \n",
"ax.spines['right'].set_color('#dddddd')\n",
"ax.spines['left'].set_color('#dddddd')\n",
"ax.tick_params(axis='x', colors='white')\n",
"ax.tick_params(axis='y', colors='white')\n",
"ax.yaxis.label.set_color('white')\n",
"ax.xaxis.label.set_color('white')\n",
"#'''\n",
"\n",
"# export\n",
"plt.grid()\n",
"plt.savefig('tanh.png', dpi=300, transparent=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3deXwc9X3/8dfu6r5ty5JlS7ItLB/yiW0MBIMhQGKSFJrEaUJaJ2kO2jQ0cUmbhCY/QtIrR5s0BcojhRBCmobSHJQawhFiDnME2+BTtmzL19qWZFv3YWm1u9/fH7NrhJDslTS7szv7fj4e+9Cudjyfj7zSe2e/850ZjzEGERFJfV6nGxAREXso0EVEXEKBLiLiEgp0ERGXUKCLiLhEhlOFjxw5YjIyJl6+t7eX/Px8GzpSjVSpkZA6+/cTCoXwLVgQvxq45zVxS41E1ZlIjUAgcKampmbqiE8aYxy5+f1+Y4dNmzbZsh7VSJ0aCamzZo1pX7o0vjWMe14Tt9RIVJ2J1GhsbNxqRslVDbmIiLiEAl1ExCUU6CIiLqFAFxFxCQW6iIhLxBLoDwCngN2jPO8B/g04COwEltvTmoiIjEUsgf4gsPY8z98A1EZutwD3TrwtEREZq1gC/QWg7TzP3wQ8BBjgVaAEqJh4ayLOCIbCnOoeYCDkdCciY+MxsZ0PfRawEVg0wnMbgW8BmyOPnwW+DGwdYdlbIjcaGxtX+P3+Mbb7dj09PRQUFEx4PaqROjXiWadrwHDvjn6+fveX8Hjg+W9/n1XT4ndAtVteE7fUSFSdidSorq7eVlNTs3LEJ0c74mjYbZYxZvcoz200xqwe8vhZY8zKC61TR4qqRrLV2dvUaS77x9+a2q8+YU4uu9Rsn73YzPzyRvOt3+y1vVaUW14Tt9RIVJ1kPlL0BFA15HFl5HsiKeXvN+4lEAzzq8++g4riHKqLvKxbUcm9z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5b6EN9EvhNnGvYaQbW/03UcewPQSfMAi7G+huxmw9rmOIU1qezeNT4V6wNnXAc1h1lsDZGthG5mL3NZgOngR9jDR3dj7VRZZtUCvTfYn3MHn67CetCHZOxPur9DfAI4LG5xr3ARVgfx5qAf4nDz/G32BOw56sB8FWsoZ2fYb1JxaNGtE4wUideNeTCCoBfAht46yc0u4Sw/i4qsT7hLLJ5/e/DerOI99zw1cByrOG2z2FtTdspI7L+e7HeXHuxeR9NrFcsSgbXnee5zwK/wnqHfQ3rXbwU693QrhpD3cf4d8yMVmMx1jt4dOu8Euvj8iqg2aYaw/0Ma1/A18e4/lhqfALrD/Faxv8RPNafw06xXBQ9lWRihfnPsP5G4qkDayfsWuzd2XsFcCPWRIQcoAj4T+BPbKwBb77Op7B25q/C3n00xyO36CeYX2BzoKfSFvr5PIq1MwOs4ZcswO6zpVUMuf9+7J+dsAsow/poPAvrhV/O2MP8QmqH3L8Ja2+73dZifTy+EeiLw/rjKZaLoqcKD9Z47V7ge3GqMZU3ZzHlAtdj/+/U7VhvrLOwXo/fYX+Y5wOFQ+6/C/v/xpuxhvPmRR5fizUDyTaptIV+Pg9EbruxdjR8HPt3zHwH62OlwZre9Gc2rz9RvoX1CxXGOn3xn8ehxt1ANtZ4Klg7Ru2u837gLqxAeRxrDPfdNqx3tIui2+3nwNVYnySPY31K+tH5/sE4XAGs582peGAN69k5Q6sC+AnW/5UXa7gzXtMK46kca6scrFz8L6zZKHb7S6xPS1lYO97/1M6V69B/ERGXcMuQi4hI2lOgi4i4hAJdRMQlFOgiIi6hQBcRcQkFuoiISyjQRURc4v8DgwVSAIW72XkAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"ax = fig.add_subplot(111)\n",
"\n",
"# generate data\n",
"x = np.arange(-6.1, 6.1, 0.1)\n",
"y = tanhDerivative(x)\n",
"ax.plot(x, y)\n",
"plt.xticks(np.arange(-6.0, 7.0, 1))\n",
"plt.yticks(np.arange(0, 1.2, 0.2))\n",
"\n",
"# red line\n",
"plt.axvline(x=0, label='line at x = {}'.format(0), c='r')\n",
"\n",
"#''' change style\n",
"# ref: https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis\n",
"ax.spines['bottom'].set_color('#dddddd')\n",
"ax.spines['top'].set_color('#dddddd') \n",
"ax.spines['right'].set_color('#dddddd')\n",
"ax.spines['left'].set_color('#dddddd')\n",
"ax.tick_params(axis='x', colors='white')\n",
"ax.tick_params(axis='y', colors='white')\n",
"ax.yaxis.label.set_color('white')\n",
"ax.xaxis.label.set_color('white')\n",
"#'''\n",
"\n",
"# export\n",
"plt.grid()\n",
"plt.savefig('tanh_derivative.png', dpi=300, transparent=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD8CAYAAABq6S8VAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAZlElEQVR4nO3deXQUdb738XcIWYBAAFlEQoDILkuEEGBgxH30onJ1HB90RAkjQdzAM85cmfGM3HG8+qCjo1yZZxghgCCICF7cRh0N112SsAUIW7M1Oxi2hKyd3/NHNSMghoSu6kqlP69z6tCdkN/32530p6qrqn8VZYxBRES8q4HbDYiISGgU5CIiHqcgFxHxOAW5iIjHKchFRDxOQS4i4nF2BfmjwHpgHbAAiLdpXBEROQ87grw98AiQBvQGooFRNowrIiI1YNcWeUOgUfDfxsBem8YVEZHzaGjDGHuA54FdQAnwUXA5W2ZwwefzDSgvLw+5cFVVFQ0aOLubXzUir0Zjvx+Akx06OFqnvjxfqhG+OnFxcYdTUlJa/+AbxphQlxb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IP8n1lvps5eRWB9oaon1du43wCIgyoE6fwUuxXrbtQ/4swM1foc9wVpdDbCmU+gAzMdaOTlR41SdymAdp2pI9RKAt4BJnPluzE4BrNdFEtY7mt42j38T1krC6fO7hwH9sXarPYi19WynhsHx/4q1Yi3GxmMwoX6yMxyqmyJgArAEa226AmuN3QprzWdnndP9nQs/4PJjNfpgrbFPbY0nYb01Tgf221TjbPOx9vU/Wcvxa1JjDKFP21DTx2GnPVgruVOSgl/zohisEJ+P9Rpx2lGsA6w3YO9B3KHALVgnGMQDzbAm5rvbxhrw/e/5INZB+nTsPQazO7iceseyGBuD3Atb5NV5G+sABVi7WWIBJ2Yva3fa7Vux/2yDfKAN1tvgTli/8P7UPsTPp+tpt0diHT2326lpG27Be9M25GA9R52x/pZGActc7ejCRGHtiy0AXnCwTmu+PyupEXAd9v9NTcZaoXbC+n18iv0h3gRoetrt67H/Nb4fa7dd9+D9a7DOKrKFF7bIqzMruKzDOnhwL84cbJmK9fbRYJ2mNN6BGuHwLNYfUhWwE2taBbv9NxCHtb8UrAOedte5FZiGFSTvYe2j/ZkN41Zi7W76EGvf7yys0+rstgC4Euvd426sd0Uzq/uBWhoKjOb70+nA2nVn99lW7YA5WM9VA6xdm+GeosMObbG2wsHKxNexzi6x28NY75BisQ6oZ9g1sD6iLyLicV7ftSIiEvEU5CIiHqcgFxHxOAW5iIjHKchFRDxOQS4i4nEKchERj/v/1uh4n898kEEAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"ax = fig.add_subplot(111)\n",
"\n",
"# generate data\n",
"x = np.arange(-6.1, 6.1, 0.1)\n",
"y = relu(x)\n",
"ax.plot(x, y)\n",
"plt.xticks(np.arange(-6.0, 7.0, 1))\n",
"plt.yticks(np.arange(-2, 10, 2))\n",
"\n",
"# red line\n",
"plt.axvline(x=0, label='line at x = {}'.format(0), c='r')\n",
"\n",
"#''' change style\n",
"# ref: https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis\n",
"ax.spines['bottom'].set_color('#dddddd')\n",
"ax.spines['top'].set_color('#dddddd') \n",
"ax.spines['right'].set_color('#dddddd')\n",
"ax.spines['left'].set_color('#dddddd')\n",
"ax.tick_params(axis='x', colors='white')\n",
"ax.tick_params(axis='y', colors='white')\n",
"ax.yaxis.label.set_color('white')\n",
"ax.xaxis.label.set_color('white')\n",
"#'''\n",
"\n",
"# export\n",
"plt.grid()\n",
"plt.savefig('relu.png', dpi=300, transparent=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAATr0lEQVR4nO3df5DcdX3H8efljmCbQ7ANdqzJSQ5jC0WDEoMOrYkFNWgnGTV2YGpGWxHriENGa4vaQYq2g1qrHUOdjhH7S6XRVodBKtZ60f4hmMQfCMRgNkUXqkURbQ+QeLuf/vH53mU9v9/vbXLf7+59vjwfM9/J7t2X7/t77O5rP/v+fvb7HQkhIElK37Jh74AkqRoGuiQ1hIEuSQ1hoEtSQxjoktQQY8MqfPfdd4exscWXf/DBB1mxYkUFe2SNVGoMpM5dd9HpdBg944z6atCcx6QpNQZVZzE1jhw58oPJyclTc38ZQhjK0m63QxWmpqYq2Y410qkxkDobN4YH1q2rt0ZozmPSlBqDqrOYGq1Wa18oyFVbLpLUEAa6JDWEgS5JDWGgS1JDGOiS1BAGuiQ1hIEuSQ0xtC8WSSm490cP8/F9bbrdek4zffe3j/CVIwdr2bY1lm6dUx7usKmG7RroUomP72vzvs99i5GRmgoE4PChm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p7iN+OqujxvuIA51uDdueFYiDkf1kF7Ov2Brg+8CHia2jXcRBVWVSCvTPET9mz1+2Ei/U8UvEj3pvAnYDIxXX+ABwOvHj2HeB99Twd7yFagK2rAbAW4mtnY8Q36TqqDFbZyarU1cNLWwc+BdgBz/7Ca0qHeLrYhXxE85ZFW//d4hvFnXPDf9N4BnEdtvriKPpKo1l2/8A8c31QSo+RtPvFYuWggtKfvda4F+J77BfJr6LryS+G1ZVo9cHOf4DM0U1nkp8B58dna8iflzeAHyvohrzfYR4LOBtx7j9fmq8kvhCPJ/j/wje799RpX4uip6SE4hh/hHia6ROPyIehN1MtQd7zwO2ECciPAZ4LPBPwMsrrAFHH+f7iAfzN1DtMZp7smX2E8wnqDjQUxqhl/kU8WAGxPbLcqDqs6U9oef2i6l+dsI3gMcTPxqfRnzgn8Gxh/lC1vbc3ko82l61zcSPx1uAh2rYfp36uSh6KkaI/doDwF/VVONUjs5i+gXgeVT/nHoz8Y31NOLj8XmqD/MVwEk9t59P9a/x7xHbeb+W3T+fOAOpMimN0Mtcly23Ew80vILqD8y8i/ixMhCnN72m4u0PyjXEJ1SXePriP6yhxk7gRGI/FeKB0arrvBh4PzFQPk3s4b6ggu0WXRS9ah8DNhE/Sd5D/JT0obL/4DicB2zn6FQ8iG29KmdoPQH4e+L/q2XEdmdd0wrr9CvEUTnEXPwocTZK1V5P/LS0nHjg/fer3Lhf/ZekhmhKy0WSHvUMdElqCANdkhrCQJekhjDQJakhDHRJaggDXZIa4v8BPAmFM6cQ9hUAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"ax = fig.add_subplot(111)\n",
"\n",
"# generate data\n",
"x = np.arange(-6.1, 6.1, 0.1)\n",
"y = reluDerivative(x)\n",
"ax.plot(x, y)\n",
"plt.xticks(np.arange(-6.0, 7.0, 1))\n",
"plt.yticks(np.arange(0, 1.0, 0.2))\n",
"\n",
"# red line\n",
"plt.axvline(x=0, label='line at x = {}'.format(0), c='r')\n",
"\n",
"#''' change style\n",
"# ref: https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis\n",
"ax.spines['bottom'].set_color('#dddddd')\n",
"ax.spines['top'].set_color('#dddddd') \n",
"ax.spines['right'].set_color('#dddddd')\n",
"ax.spines['left'].set_color('#dddddd')\n",
"ax.tick_params(axis='x', colors='white')\n",
"ax.tick_params(axis='y', colors='white')\n",
"ax.yaxis.label.set_color('white')\n",
"ax.xaxis.label.set_color('white')\n",
"#'''\n",
"\n",
"# export\n",
"plt.grid()\n",
"plt.savefig('relu_derivative.png', dpi=300, transparent=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD8CAYAAABq6S8VAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAb4ElEQVR4nO3deXhUVZ7/8Xf2BLIAsoiELbKLECEEaFDErfWHymjbjtqihBYQd5+2e6Tbp3Xa9qc/tXXUkf41LQQQBBWXcW21FUbHjSTsEFmKLSyyGCBkT1XO/HELCFtIqHvr5qY+r+e5T2pJzvdUJfnUqXNvnRtljEFERLwr2u0OiIhIaBTkIiIepyAXEfE4BbmIiMcpyEVEPE5BLiLicXYF+YPAGmA1MB9ItKldERE5DTuCvBNwH5AF9AdigJtsaFdERBrArhF5LJAU/NoC2GlTuyIichqxNrSxA3gW2AZUAJ8Gt+NNCm74fL7B1dXVIReura0lOtrZaX7ViLwaLYqKACjv3NnROs3l+VKN8NVJSEjYl5GR0e6EO4wxoW6tjTFfGGPaGWPijDHvGmNure9nioqKjB0WLVpkSzuqoRrHGDXK7B840PEy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+3wsg3X4r1lG/KwnqPuWH9LNwHvudqjMxOFNRdbCDznYJ12HD0qKQm4HPv/pqZivaB2w/p9fIH9Id4SSKlz+Qrs/x//EWvarnfw+qVYRxXZwgsj8vrMDG6rsXYe3I4zO1uexnr7aLAOU5rsQI1weArrD6kW2Iq1rILd/hNIwJovBWuHp911rgNewgqSD7HmaH9uQ7t+rOmmT7DmfmdiHVZnt/nAxVjvHrdjvSuaUd8PNNIIYBxHD6cDa+rO7qOtOgKzsZ6raKypzXAv0WGHDlijcLAy8TWso0vsdi/WO6R4rB3qOXY1rI/oi4h4nNenVkREIp6CXETE4xTkIiIepyAXEfE4BbmIiMcpyEVEPE5BLiLicf8LsH5mqhyhz28AAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "dark"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure()\n",
"ax = fig.add_subplot(111)\n",
"\n",
"# generate data\n",
"x = np.arange(-6.1, 6.1, 0.1)\n",
"y = leaky(x)\n",
"ax.plot(x, y)\n",
"plt.xticks(np.arange(-6.0, 7.0, 1))\n",
"plt.yticks(np.arange(-2, 10, 2))\n",
"\n",
"# red line\n",
"plt.axvline(x=0, label='line at x = {}'.format(0), c='r')\n",
"\n",
"#''' change style\n",
"# ref: https://stackoverflow.com/questions/1982770/matplotlib-changing-the-color-of-an-axis\n",
"ax.spines['bottom'].set_color('#dddddd')\n",
"ax.spines['top'].set_color('#dddddd') \n",
"ax.spines['right'].set_color('#dddddd')\n",
"ax.spines['left'].set_color('#dddddd')\n",
"ax.tick_params(axis='x', colors='white')\n",
"ax.tick_params(axis='y', colors='white')\n",
"ax.yaxis.label.set_color('white')\n",
"ax.xaxis.label.set_color('white')\n",
"#'''\n",
"\n",
"# export\n",
"plt.grid()\n",
"plt.savefig('leaky.png', dpi=300, transparent=True)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment