From 197b11ba04d5cb74847ab5e3470d86df8495c934 Mon Sep 17 00:00:00 2001 From: AntreasAntoniou Date: Mon, 2 Oct 2017 01:24:09 +0100 Subject: [PATCH] Minor fixes in the notebooks --- notebooks/02_Single_layer_models.ipynb | 99 +++++--------------------- 1 file changed, 16 insertions(+), 83 deletions(-) diff --git a/notebooks/02_Single_layer_models.ipynb b/notebooks/02_Single_layer_models.ipynb index a5b79cb..3b5a09f 100644 --- a/notebooks/02_Single_layer_models.ipynb +++ b/notebooks/02_Single_layer_models.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -92,17 +92,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1.88 ms ± 26.5 µs per loop (mean ± std. dev. of 3 runs, 100 loops each)\n" - ] - } - ], + "outputs": [], "source": [ "%%timeit -n 100 -r 3\n", "c = np.empty(size)\n", @@ -119,17 +111,9 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3.17 µs ± 1.87 µs per loop (mean ± std. dev. of 3 runs, 100 loops each)\n" - ] - } - ], + "outputs": [], "source": [ "%%timeit -n 100 -r 3\n", "c = a + b" @@ -168,7 +152,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -199,22 +183,9 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "NotImplementedError", - "evalue": "Delete this raise command and write your code here instead.", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNotImplementedError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mtrue_outputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m6.\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m6.\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m17.\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m50.\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mallclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfprop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minputs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mweights\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbiases\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtrue_outputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Wrong outputs computed.'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36mfprop\u001b[0;34m(inputs, weights, biases)\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0moutputs\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mArray\u001b[0m \u001b[0mof\u001b[0m \u001b[0mlayer\u001b[0m \u001b[0moutputs\u001b[0m \u001b[0mof\u001b[0m \u001b[0mshape\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mbatch_size\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutput_dim\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \"\"\"\n\u001b[0;32m---> 16\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mNotImplementedError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Delete this raise command and write your code here instead.'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mNotImplementedError\u001b[0m: Delete this raise command and write your code here instead." - ] - } - ], + "outputs": [], "source": [ "inputs = np.array([[0., -1., 2.], [-6., 3., 1.]])\n", "weights = np.array([[2., -3., -1.], [-5., 7., 2.]])\n", @@ -242,25 +213,9 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 6. 6. 6.]\n", - " [ 24. 24. 24.]\n", - " [ 42. 42. 42.]]\n", - "[[ 18. 24. 30.]\n", - " [ 18. 24. 30.]\n", - " [ 18. 24. 30.]]\n", - "[ 0.8 2.6 4.4]\n", - "[ 2.4 3. 3.6]\n", - "0.2\n" - ] - } - ], + "outputs": [], "source": [ "# Initiliase arrays with arbitrary values\n", "A = np.arange(9).reshape((3, 3))\n", @@ -285,25 +240,9 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 0.1 1.2]\n", - " [ 2.1 3.2]\n", - " [ 4.1 5.2]]\n", - "[[-1. 0.]\n", - " [ 2. 3.]\n", - " [ 5. 6.]]\n", - "[[ 0. 0.2]\n", - " [ 0.2 0.6]\n", - " [ 0.4 1. ]]\n" - ] - } - ], + "outputs": [], "source": [ "# Initiliase arrays with arbitrary values\n", "A = np.arange(6).reshape((3, 2))\n", @@ -337,9 +276,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", @@ -455,9 +392,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "def error(outputs, targets):\n", @@ -556,9 +491,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "def grads_wrt_params(inputs, grads_wrt_outputs):\n",