1 of 94

Zo werkt een �neuraal netwerk

Schrijver: Brandon Rohrer. �NL vertaling: Martijn de Boer

2 of 94

Een afbeelding met vier pixels

3 of 94

Een afbeelding met vier pixels

solide

verticaal

diagonaal

horizontaal

4 of 94

Afbeeldingen Categoriseren

solide

verticaal

diagonaal

horizontaal

5 of 94

Afbeeldingen Categoriseren

solide

verticaal

diagonaal

horizontaal

6 of 94

Afbeeldingen Categoriseren

solide

verticaal

diagonaal

horizontaal

7 of 94

Eenvoudige regels zijn niet genoeg

solide

verticaal

diagonaal

horizontaal

8 of 94

Eenvoudige regels zijn niet genoeg

solid

vertical

diagonal

horizontal

9 of 94

Invoer neuronen

10 of 94

Pixel helderheid

-1.0

-.75

-.50

-.25

0.0

+.25

+.50

+.75

+1.0

11 of 94

Invoer vector

.75

-.75

0.0

.50

12 of 94

Receptieve velden

13 of 94

Een neuron

+

14 of 94

De totaalsom van alle invoers

+

.75

-.75

0.0

.50

.50

.50

0.00

-.75

  • .75

.50

15 of 94

Gewichten (Weights)

+

.75

-.75

0.0

.50

.50

1.0

1.0

1.0

1.0

.50

0.00

-.75

  • .75

.50

x 1.0

x 1.0

x 1.0

x 1.0

16 of 94

Gewichten (Weights)

+

.75

-.75

0.0

.50

-1.075

-.2

0.0

.8

-.5

.50

0.00

-.75

  • .75

-1.075

-.2

0.0

.8

-.5

x

x

x

x

17 of 94

Gewichten (Weights)

+

.75

-.75

0.0

.50

-1.075

-.2

0.0

.8

-.5

.50

0.00

-.75

  • .75

-1.075

-.2

0.0

.8

-.5

x

x

x

x

18 of 94

Activeer het resultaat

+

.75

-.75

0.0

.50

1.075

.746

19 of 94

Sigmoid activatie functie

1.0

.5

-1.0

-.5

1.0

.5

1.5

2.0

-1.0

-.5

-1.5

-2.0

20 of 94

Sigmoid activatie functie

1.0

.5

-1.0

-.5

1.0

.5

1.5

2.0

-1.0

-.5

-1.5

-2.0

Jouw nummer gaat hier in

21 of 94

Sigmoid activatie functie

1.0

.5

-1.0

-.5

1.0

.5

1.5

2.0

-1.0

-.5

-1.5

-2.0

22 of 94

Sigmoid activatie functie

1.0

.5

-1.0

-.5

1.0

.5

1.5

2.0

-1.0

-.5

-1.5

-2.0

De verbroken versie �komt hier uit

23 of 94

Sigmoid activatie functie

1.0

.5

-1.0

-.5

1.0

.5

1.5

2.0

-1.0

-.5

-1.5

-2.0

24 of 94

Sigmoid activatie functie

1.0

.5

-1.0

-.5

1.0

.5

1.5

2.0

-1.0

-.5

-1.5

-2.0

25 of 94

Het maakt niet uit met welke waarde je start, het antwoord blijft altijd tussen -1 en 1.

1.0

.5

-1.0

-.5

1.0

.5

1.5

2.0

-1.0

-.5

-1.5

-2.0

26 of 94

Verbreek het resultaat

+

.75

-.75

0.0

.50

1.075

.746

27 of 94

Gewogen optel-en-verbreek neuronen

.75

-.75

0.0

.50

.746

28 of 94

Maak veel van de neuronen in het netwerk identiek, dit met uitzondering van de gewichten (Weights)

Ter verduidelijking,�de gewichten zijn:

1.0 (wit)

-1.0 (zwart) of

0.0 (missend)

29 of 94

De ontvangende velden worden steeds complexer

30 of 94

Herhaal dit ook voor de additionele lagen (additional layers) van je netwerk indien van toepassing!

31 of 94

De ontvangende velden worden nu nog complexer

32 of 94

Herhaal dit met variatie (variation)

33 of 94

Gerectificeerde lineaire eenheden (ReLUs)

1.0

.5

-1.0

-.5

1.0

.5

1.5

2.0

-1.0

-.5

-1.5

-2.0

Als het nummer positief is dan blijft het behouden, anders krijg het een nul waarde.

34 of 94

35 of 94

Voeg een uitvoer (output) laag toe

solide

verticaal

diagonaal

horizontaal

36 of 94

solide

verticaal

diagonaal

horizontaal

37 of 94

solide

verticaal

diagonaal

horizontaal

38 of 94

solide

verticaal

diagonaal

horizontaal

39 of 94

solide

verticaal

diagonaal

horizontaal

40 of 94

solide

verticaal

diagonaal

horizontaal

41 of 94

solide

verticaal

diagonaal

horizontaal

42 of 94

solide

verticaal

diagonaal

horizontaal

43 of 94

Fouten (Errors)

solide

verticaal

diagonaal

horizontaal

1.

0.

0.

0.

waarheid

44 of 94

Fouten (Errors)

solide

verticaal

diagonaal

horizontaal

-.75

-.25

.75

.5

1.

0.

0.

0.

waarheid

antwoord

45 of 94

Fouten (Errors)

solide

verticaal

diagonaal

horizontaal

-.75

-.25

.75

.5

1.

0.

0.

0.

waarheid

antwoord

fouten

1.75

.25

.75

.5

46 of 94

Fouten (Errors)

solide

verticaal

diagonaal

horizontaal

-.75

-.25

.75

.5

1.

0.

0.

0.

waarheid

andwoord

fouten

1.75

.25

.75

.5

totaal

3.25

47 of 94

Leer alle gewichten (Weights): Gradient descent

Fout bij:

Gewicht

Origineel gewicht

48 of 94

Leer alle gewichten (Weights): Gradient descent

Fout bij:

Gewicht

origineel gewicht

lager gewicht

49 of 94

Leer alle gewichten (Weights): Gradient descent

Fout bij:

Gewichten

origineel gewicht

lager gewicht

hoger gewicht

50 of 94

Het numeriek calculeren van de Gradiënt is duur

Fout bij:

Gewicht

origineel gewicht

lager gewicht

hoger gewicht

51 of 94

Het numeriek calculeren van de Gradiënt is heel duur

52 of 94

Het direct calculeren van de Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

53 of 94

Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

de verandering in het�gewicht (Weight) = +1

54 of 94

Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

de verandering in het�gewicht (Weight) = +1

beweeg langs de �kromme lijn (curve)

55 of 94

Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

de verandering in het�gewicht (Weight) = +1

de verandering in �de fout (error) = -2

56 of 94

Slope = gradient = helling

Fout bij:

Gewicht

origineel gewicht

de verandering in het�gewicht (Weight) = +1

de verandering in �de fout (error) = -2

gradient = verandering in fouten

verandering in gewichten

57 of 94

Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

de verandering in het�gewicht (Weight) = +1

de verandering in �de fout (error) = -2

gradient = verandering in fout

verandering in gewicht

= ∆ fout

∆ gewicht

= d(fout)

d(gewicht)

= ∂e

∂w

58 of 94

Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

de verandering in �gewicht (Weight) = +1

verandering in de �fout (error) = -2

Gradient = verandering fouten

verandering gewicht

= ∆ fout

∆ gewicht

= d(fout)

d(gewicht)

= ∂e

∂w

= -2 = -2

+1

59 of 94

Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

Men moet de fout (error) functie weten.

Bijvoorbeeld:

fout = gewicht ^2

0

-1

+1

60 of 94

Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

Men moet de fout (error) functie weten.

Bijvoorbeeld:

fout = gewicht ^2

∂e = 2 * gewicht

∂w

0

-1

+1

61 of 94

Gradiënt (slope)

Fout bij:

Gewicht

origineel gewicht

Men moet de fout (error) functie weten.

Bijvoorbeeld:

fout = gewicht ^2

∂e = 2 * gewicht

∂w

= 2 * -1

= -2

0

-1

+1

62 of 94

Ketenen

y = x * w1

+

+

x

(invoer)

e

(uitvoer)

y

(tussenwaarde)

w1

w2

63 of 94

Ketenen

y = x * w1

∂y = x

∂w1

+

+

x

(invoer)

e

(uitvoer)

y

(tussenwaarde)

w1

w2

64 of 94

Ketenen

y = x * w1

∂y = x

∂w1

e = y * w2

∂e = w2

∂y

+

+

x

(invoer)

e

(uitvoer)

y

(tussenwaarde)

w1

w2

65 of 94

Ketenen

y = x * w1

∂y = x

∂w1

e = y * w2

∂e = w2

∂y

e = x * w1 * w2

∂e = x * w2

∂w1

+

+

x

(invoer)

e

(invoer)

y

(tussenwaarde)

w1

w2

66 of 94

Ketenen

y = x * w1

∂y = x

∂w1

e = y * w2

∂e = w2

∂y

e = x * w1 * w2

∂e = x * w2

∂w1

∂e = ∂y * ∂e

∂w1 ∂w1 ∂y

+

+

x

(invoer)

e

(uitvoer)

y

(tussenwaarde)

w1

w2

67 of 94

Ketenen

y = x * w1

∂y = x

∂w1

e = y * w2

∂e = w2

∂y

e = x * w1 * w2

∂e = x * w2

∂w1

∂e = ∂y * ∂e

∂w1 ∂w1 ∂y

+

+

x

(invoer)

e

(uitvoer)

y

(tussenwaarde)

w1

w2

68 of 94

Ketenen

∂fout = ∂a * ∂b * ∂c * ∂d * … * ∂y * ∂z * ∂fout

∂gewicht ∂gewicht ∂a ∂b ∂c ∂x ∂y ∂z

+

fout

a

gewicht

b

c

x

y

z

...

69 of 94

Terugwaartse propagatie (Backpropagation)

∂fout = ∂a * ∂b * ∂c * ∂d * … * ∂y * ∂z * ∂fout

∂gewicht ∂gewicht ∂a ∂b ∂c ∂x ∂y ∂z

+

fout

a

gewicht

b

c

x

y

z

...

70 of 94

Terugwaartse propagatie (Backpropagation)

∂fout = ∂a * ∂b * ∂c * ∂d * … * ∂y * ∂z * ∂fout

∂gewicht ∂gewicht ∂a ∂b ∂c ∂x ∂y ∂z

+

fout

a

gewicht

b

c

x

y

z

...

71 of 94

Terugwaartse propagatie (Backpropagation)

∂fout = ∂a * ∂b * ∂c * ∂d * … * ∂y * ∂z * ∂fout

∂gewicht ∂gewicht ∂a ∂b ∂c ∂x ∂y ∂z

+

fout

a

gewicht

b

c

x

y

z

...

72 of 94

Terugwaartse propagatie (Backpropagation)

∂fout = ∂a * ∂b * ∂c * ∂d * … * ∂y * ∂z * ∂fout

∂gewicht ∂gewicht ∂a ∂b ∂c ∂x ∂y ∂z

+

fout

a

gewicht

b

c

x

y

z

...

73 of 94

Terugwaartse propagatie (Backpropagation)

∂err = ∂a * ∂b * ∂c * ∂d * … * ∂y * ∂z * ∂fout

∂gewicht ∂gewicht ∂a ∂b ∂c ∂x ∂y ∂z

+

fout

a

gewicht

b

c

x

y

z

...

74 of 94

Terugwaartse propagatie (Backpropagation)

∂fout = ∂a * ∂b * ∂c * ∂d * … * ∂y * ∂z * ∂fout

∂gewicht ∂gewicht ∂a ∂b ∂c ∂x ∂y ∂z

+

fout

a

gewicht

b

c

x

y

z

...

75 of 94

Terugwaartse propagatie (Backpropagation)

∂fout = ∂a * ∂b * ∂c * ∂d * … * ∂y * ∂z * ∂fout

∂gewicht ∂gewicht ∂a ∂b ∂c ∂x ∂y ∂z

+

fout

a

gewicht

b

c

x

y

z

...

76 of 94

Terugwaartse propagatie uitdaging: gewichten

+

+

a

b

w

77 of 94

Terugwaartse propagatie uitdaging: gewichten

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

w

78 of 94

Terugwaartse propagatie uitdaging: gewichten

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

w

b = wa

79 of 94

Terugwaartse propagatie uitdaging: gewichten

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

w

b = wa

∂b = w

∂a

80 of 94

Terugwaartse propagatie uitdaging: sommen

+

+

a

z

b

c

d

...

81 of 94

Terugwaartse propagatie uitdaging: sommen

∂fout= ∂z * ∂fout

∂a ∂a ∂z

+

+

a

z

b

c

d

...

82 of 94

Terugwaartse propagatie uitdaging: sommen

∂fout = ∂z * ∂fout

∂a ∂a ∂z

+

+

a

z

z = a + b + c + d + ...

b

c

d

...

83 of 94

Terugwaartse propagatie uitdaging: sommen

∂fout= ∂z * ∂fout

∂a ∂a ∂z

+

+

a

z

z = a + b + c + d + ...

∂z = 1

∂a

b

c

d

...

84 of 94

Terugwaartse propagatie uitdaging: sigmoid

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

85 of 94

Terugwaartse propagatie uitdaging: sigmoid

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

b = 1

1 + e

-a

86 of 94

Terugwaartse propagatie uitdaging: sigmoid

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

b = 1

1 + e

= 𝝈(a)

-a

87 of 94

Terugwaartse propagatie uitdaging: sigmoid

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

b = 1

1 + e

= 𝝈(a)

Omdat wiskunde heel mooi is �/ dom geluk:

∂b = 𝝈(a) * (1 - 𝝈(a))

∂a

-a

88 of 94

Terugwaartse propagatie uitdaging: ReLu

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

89 of 94

Terugwaartse propagatie uitdaging: ReLu

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

b = a , a > 0

= 0 , anderszins

90 of 94

Terugwaartse propagatie uitdaging: ReLu

∂fout = ∂b * ∂fout

∂a ∂a ∂b

+

+

a

b

b = a , a > 0

= 0 , anderszins

∂b = 1 , a > 0

∂a 0 , anderszins

91 of 94

Training vanaf het begin

solide

verticaal

diagonaal

horizontaal

92 of 94

Eindresultaat

solide

verticaal

diagonaal

horizontaal

93 of 94

Geavanceerde onderwerpen (Engels)

Bias neurons

Dropout

Backpropagation details

Andrej Karpathy’s Stanford CS231 lecture

Backpropagation gotchas

Andrej Karpathy’s article “Yes you should understand backprop”

Tips and tricks

Nikolas Markou’s article “The Black Magic of Deep Learning”

94 of 94

For more How it Works:

How Deep Learning works

How Convolutional Neural Networks work

How Bayes Law works

How data science works

How linear regression works

These slides

https://docs.google.com/presentation/d/1AAEFCgC0Ja7QEl3-wmuvIizbvaE-aQRksc7-W8LR2GY/edit?usp=sharing