From 36c4cd352b10f9cd7ccdee65976700d0c0f3e5f4 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Mon, 23 Oct 2023 07:25:11 +0200 Subject: [PATCH] correcting slides --- doc/pub/week43/html/week43-bs.html | 11 +- doc/pub/week43/html/week43-reveal.html | 4 +- doc/pub/week43/html/week43-solarized.html | 9 +- doc/pub/week43/html/week43.html | 9 +- doc/pub/week43/ipynb/ipynb-week43-src.tar.gz | Bin 192 -> 192 bytes doc/pub/week43/ipynb/week43.ipynb | 480 ++++++++++--------- doc/src/week43/exercisesweek43.ipynb | 169 ------- doc/src/week43/week43.do.txt | 4 +- 8 files changed, 266 insertions(+), 420 deletions(-) delete mode 100644 doc/src/week43/exercisesweek43.ipynb diff --git a/doc/pub/week43/html/week43-bs.html b/doc/pub/week43/html/week43-bs.html index 13f312487..5a12f18c2 100644 --- a/doc/pub/week43/html/week43-bs.html +++ b/doc/pub/week43/html/week43-bs.html @@ -49,11 +49,11 @@ doconce format html week43.do.txt --html_style=bootstrap --pygments_html_style=d 2, None, 'material-for-exercises-week-43-and-week-44'), - ('Writing our first neural network code, Testing our code for ' - 'the OR and XOR gates', + ('Writing our first neural network code, testing it for the OR ' + 'and XOR gates', 2, None, - 'writing-our-first-neural-network-code-testing-our-code-for-the-or-and-xor-gates'), + 'writing-our-first-neural-network-code-testing-it-for-the-or-and-xor-gates'), ('The AND and XOR Gates', 2, None, 'the-and-and-xor-gates'), ('Representing the Data Sets', 2, @@ -330,7 +330,7 @@ MathJax.Hub.Config({
  • Using Automatic differentiation
  • Back propagation and automatic differentiation
  • Material for exercises week 43 and week 44
  • -
  • Writing our first neural network code, Testing our code for the OR and XOR gates
  • +
  • Writing our first neural network code, testing it for the OR and XOR gates
  • The AND and XOR Gates
  • Representing the Data Sets
  • Setting up the Neural Network
  • @@ -515,7 +515,7 @@ t

    Material for exercises week 43 and week 44

    -

    Writing our first neural network code, Testing our code for the OR and XOR gates

    +

    Writing our first neural network code, testing it for the OR and XOR gates

    During week 41 we discussed three different types of gates, the so-called XOR, the OR and the AND gates. In order to develop a code @@ -779,6 +779,7 @@ plt.show() +

    How do we interpret these results?

    Lecture Thursday October 26

    diff --git a/doc/pub/week43/html/week43-reveal.html b/doc/pub/week43/html/week43-reveal.html index 0a82957ca..874befd13 100644 --- a/doc/pub/week43/html/week43-reveal.html +++ b/doc/pub/week43/html/week43-reveal.html @@ -269,7 +269,7 @@ t
    -

    Writing our first neural network code, Testing our code for the OR and XOR gates

    +

    Writing our first neural network code, testing it for the OR and XOR gates

    During week 41 we discussed three different types of gates, the so-called XOR, the OR and the AND gates. In order to develop a code @@ -526,6 +526,8 @@ plt.show() + +

    How do we interpret these results?

    diff --git a/doc/pub/week43/html/week43-solarized.html b/doc/pub/week43/html/week43-solarized.html index e93caeb3b..858f43905 100644 --- a/doc/pub/week43/html/week43-solarized.html +++ b/doc/pub/week43/html/week43-solarized.html @@ -76,11 +76,11 @@ div.toc p,a { 2, None, 'material-for-exercises-week-43-and-week-44'), - ('Writing our first neural network code, Testing our code for ' - 'the OR and XOR gates', + ('Writing our first neural network code, testing it for the OR ' + 'and XOR gates', 2, None, - 'writing-our-first-neural-network-code-testing-our-code-for-the-or-and-xor-gates'), + 'writing-our-first-neural-network-code-testing-it-for-the-or-and-xor-gates'), ('The AND and XOR Gates', 2, None, 'the-and-and-xor-gates'), ('Representing the Data Sets', 2, @@ -416,7 +416,7 @@ t

    Material for exercises week 43 and week 44











    -

    Writing our first neural network code, Testing our code for the OR and XOR gates

    +

    Writing our first neural network code, testing it for the OR and XOR gates

    During week 41 we discussed three different types of gates, the so-called XOR, the OR and the AND gates. In order to develop a code @@ -668,6 +668,7 @@ plt.show() +

    How do we interpret these results?











    Lecture Thursday October 26

    diff --git a/doc/pub/week43/html/week43.html b/doc/pub/week43/html/week43.html index c8e585927..4d290c546 100644 --- a/doc/pub/week43/html/week43.html +++ b/doc/pub/week43/html/week43.html @@ -153,11 +153,11 @@ div.toc p,a { 2, None, 'material-for-exercises-week-43-and-week-44'), - ('Writing our first neural network code, Testing our code for ' - 'the OR and XOR gates', + ('Writing our first neural network code, testing it for the OR ' + 'and XOR gates', 2, None, - 'writing-our-first-neural-network-code-testing-our-code-for-the-or-and-xor-gates'), + 'writing-our-first-neural-network-code-testing-it-for-the-or-and-xor-gates'), ('The AND and XOR Gates', 2, None, 'the-and-and-xor-gates'), ('Representing the Data Sets', 2, @@ -493,7 +493,7 @@ t

    Material for exercises week 43 and week 44











    -

    Writing our first neural network code, Testing our code for the OR and XOR gates

    +

    Writing our first neural network code, testing it for the OR and XOR gates

    During week 41 we discussed three different types of gates, the so-called XOR, the OR and the AND gates. In order to develop a code @@ -745,6 +745,7 @@ plt.show() +

    How do we interpret these results?











    Lecture Thursday October 26

    diff --git a/doc/pub/week43/ipynb/ipynb-week43-src.tar.gz b/doc/pub/week43/ipynb/ipynb-week43-src.tar.gz index 71628489c60ac9c48ff5a1e53250345b4421c7b2..e3ea0bcecfa3b6fa645cb23d199f5c759175c06e 100644 GIT binary patch delta 122 zcmV-=0EPd+0l)zVABzY8s{=NX2Ty8pMrgugAT;KyGyt;PNiUss!VIT0)ftsV^=@t$ zE6Wdi=2zgEf8tn43)_9~Dy=|ihq=}@+z@LPN3!iz4uwWLw!q-ElLkSk9z;<{C$$on cur>N*L}R1y*UxyK=Xqay0B9w`{Qw9607?)wCIA2c delta 122 zcmV-=0EPd+0l)zVABzY8j{h~02TyA9I876p0HHBws{qJyC%tsm2{WA1RA*Ec)w{W2 ztSmq5nO}it{)uBHEo}F_tF!{89p+lsa6_zF9Lcs\n", - "" - ] - }, - { - "cell_type": "markdown", - "id": "b661b3a0", - "metadata": { - "editable": true - }, - "source": [ - "# Exercises weeks 43 and 44 \n", - "**October 9-13, 2023**\n", - "\n", - "Date: **Deadline is Sunday November 5 at midnight**\n", - "\n", - "You can hand in the exercises from week 43 and week 44 as one exercise and get a total score of two additional points." - ] - }, - { - "cell_type": "markdown", - "id": "01487b34", - "metadata": { - "editable": true - }, - "source": [ - "# Overarching aims of the exercises weeks 43 and 44\n", - "\n", - "The aim of the exercises this week and next week is to get started with writing a neural network code\n", - "of relevance for project 2. \n", - "\n", - "During week 41 we discussed three different types of gates, the\n", - "so-called XOR, the OR and the AND gates. In order to develop a code\n", - "for neural networks, it can be useful to set up a simpler system with\n", - "only two inputs and one output. This can make it easier to debug and\n", - "study the feed forward pass and the back propagation part. In the\n", - "exercise this and next week, we propose to study this system with just\n", - "one hidden layer and two hidden nodes. There is only one output node\n", - "and we can choose to use either a simple regression case (fitting a\n", - "line) or just a binary classification case with the cross-entropy as\n", - "cost function.\n", - "\n", - "Their inputs and outputs can be\n", - "summarized using the following tables, first for the OR gate with\n", - "inputs $x_1$ and $x_2$ and outputs $y$:\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
    $x_1$ $x_2$ $y$
    0 0 0
    0 1 1
    1 0 1
    1 1 1
    " - ] - }, - { - "cell_type": "markdown", - "id": "e8f2df30", - "metadata": { - "editable": true - }, - "source": [ - "## The AND and XOR Gates\n", - "\n", - "The AND gate is defined as\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
    $x_1$ $x_2$ $y$
    0 0 0
    0 1 0
    1 0 0
    1 1 1
    \n", - "\n", - "And finally we have the XOR gate\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
    $x_1$ $x_2$ $y$
    0 0 0
    0 1 1
    1 0 1
    1 1 0
    " - ] - }, - { - "cell_type": "markdown", - "id": "a3d25110", - "metadata": { - "editable": true - }, - "source": [ - "## Representing the Data Sets\n", - "\n", - "Our design matrix is defined by the input values $x_1$ and $x_2$. Since we have four possible outputs, our design matrix reads" - ] - }, - { - "cell_type": "markdown", - "id": "abdf765d", - "metadata": { - "editable": true - }, - "source": [ - "$$\n", - "\\boldsymbol{X}=\\begin{bmatrix} 0 & 0 \\\\\n", - " 0 & 1 \\\\\n", - "\t\t 1 & 0 \\\\\n", - "\t\t 1 & 1 \\end{bmatrix},\n", - "$$" - ] - }, - { - "cell_type": "markdown", - "id": "684ff136", - "metadata": { - "editable": true - }, - "source": [ - "while the vector of outputs is $\\boldsymbol{y}^T=[0,1,1,0]$ for the XOR gate, $\\boldsymbol{y}^T=[0,0,0,1]$ for the AND gate and $\\boldsymbol{y}^T=[0,1,1,1]$ for the OR gate.\n", - "\n", - "Your tasks here are\n", - "\n", - "1. Set up the design matrix with the inputs as discussed above and a vector containing the output, the so-called targets. Note that the design matrix is the same for all gates. You need just to define different outputs.\n", - "\n", - "2. Construct a neural network with only one hidden layer and two hidden nodes using the Sigmoid function as activation function.\n", - "\n", - "3. Set up the output layer with only one output node and use again the Sigmoid function as activation function for the output.\n", - "\n", - "4. Initialize the weights and biases and perform a feed forward pass and compare the outputs with the targets.\n", - "\n", - "5. Set up the cost function (cross entropy for classification of binary cases).\n", - "\n", - "6. Calculate the gradients needed for the back propagation part.\n", - "\n", - "7. Use the gradients to train the network in the back propagation part. Think of using automatic differentiation.\n", - "\n", - "8. Train the network and study your results and compare with results obtained either with **scikit-learn** or **TensorFlow**.\n", - "\n", - "Everything you develop here can be used directly into the code for the project." - ] - } - ], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/doc/src/week43/week43.do.txt b/doc/src/week43/week43.do.txt index 06079e6d4..5bf4097b6 100644 --- a/doc/src/week43/week43.do.txt +++ b/doc/src/week43/week43.do.txt @@ -46,7 +46,7 @@ o Slides 12-44 at URL":http://cs231n.stanford.edu/slides/2017/cs231n_2017_lectur ===== Material for exercises week 43 and week 44 ===== !split -===== Writing our first neural network code, Testing our code for the OR and XOR gates ===== +===== Writing our first neural network code, testing it for the OR and XOR gates ===== During week 41 we discussed three different types of gates, the so-called XOR, the OR and the AND gates. In order to develop a code @@ -252,7 +252,7 @@ plt.show() !ec - +How do we interpret these results?