Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

0

Share

Download to read offline

Restricted Boltzmann Machines (RBM)

Download to read offline

Slides for this video
https://www.youtube.com/watch?v=Fkw0_aAtwIw

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Restricted Boltzmann Machines (RBM)

  1. 1. A friendly introduction to Restricted Boltzmann Machines (RBM) Luis Serrano
  2. 2. The mystery
  3. 3. Aisha Beto Cameron Mystery
  4. 4. Aisha Mystery
  5. 5. Beto Mystery
  6. 6. Cameron Mystery
  7. 7. Aisha Cameron Mystery
  8. 8. Beto Cameron Mystery
  9. 9. Beto Cameron Mystery Aisha Don’t like himUgh, Beto… Aisha and Cameron? Nope
  10. 10. Beto Cameron Mystery Aisha Aisha? Beto?Who are they? No clue who they are.
  11. 11. Beto Cameron Solution Aisha Descartes Euler WOOF YEAH!DOGS!!! I LOVE CATS!
  12. 12. Beto Cameron Weights Aisha Descartes Euler 4 -2 2 2 -2 -4 1 1 1 12 Hidden Layer Visible Layer
  13. 13. Restricted Boltzmann Machine (RBM) 4 -2 2 2 -2 -4 1 1 1 12 Hidden Layer Visible Layer
  14. 14. Scores
  15. 15. Beto Cameron Scores Aisha Descartes Euler 4 -2 2 2 -2 -4 1 1 1 12 Participants Score B CA D E4 -2 2 2 -2 -4 1 1 1 12
  16. 16. Beto Cameron Scores Aisha Descartes Euler 4 -2 2 2 -2 -4 1 1 1 12 Participants Score B CA D E 4 -222 -2 -4 1 1 112 6
  17. 17. Cameron Scores Aisha Descartes 2 2 1 1 2 Participants Score 2 2 1 1 2 B CA D E
  18. 18. Cameron Scores Aisha Descartes 2 2 1 1 2 Participants Score 22 1 12 8 B CA D E
  19. 19. Beto Scores Descartes -4 1 2 Participants Score -4 1 2 B CA D E
  20. 20. Beto Scores Descartes -4 1 2 Participants Score -4 12 B CA D E -1
  21. 21. Scenario Score None 0 A 1 B 1 C 1 D 2 E 1 AB 2 AC 2 AD 5 AE 0 BC 2 BD -2 BE 7 CD 5 CE 0 DE 3 ABC 3 ABD 1 ABE 6 ACD 8 ACE -1 ADE 4 BCD 1 BCE 6 BDE 4 CDE 4 ABCD 4 ABCE 5 ABDE 5 ACDE 5 BCDE 5 ABCDE 6 Beto Cameron Scores Aisha Descartes Euler 4 -2 2 2 -2 -4 1 1 1 12
  22. 22. Scenario Score None 0 A 1 B 1 C 1 D 2 E 1 AB 2 AC 2 AD 5 AE 0 BC 2 BD -2 BE 7 CD 5 CE 0 DE 3 ABC 3 ABD 1 ABE 6 ACD 8 ACE -1 ADE 4 BCD 1 BCE 6 BDE 4 CDE 4 ABCD 4 ABCE 5 ABDE 5 ACDE 5 BCDE 5 ABCDE 6 Beto Cameron Scores Aisha Descartes Euler 4 -2 2 2 -2 -4 1 1 1 12
  23. 23. Restricted Boltzmann Machine (RBM) 4 -2 2 2 -2 -4 1 1 1 12 Hidden Layer Visible Layer E = − ∑ i bivi − ∑ i aihi − ∑ i,j Wijvihj Energy = -Score
  24. 24. Probabilities
  25. 25. Scores to probabilities Sum = 6 Score Probability 3 1/2 2 1/3 1 1/6 Sum = 1
  26. 26. Scores to probabilities Sum = 0 Score Probability 1 1/0 0 0/0 -1 -1/0
  27. 27. Scores to probabilities Sum = 4.086 Score escore Normalize 1 e1 = 2.718 0.665 0 e0 = 1 0.245 -1 e-1 = 0.368 0.09 Sum = 1
  28. 28. Beto CameronAisha Descartes Euler 4 -2 2 2 -2 -4 1 1 1 12 Scenario Score eScore Probability None 0 1 0 A 1 2.72 0 B 1 2.72 0 C 1 2.72 0 D 2 7.38 0 E 1 2.72 0 AB 2 7.38 0 AC 2 7.38 0 AD 5 148.41 0.02 AE 0 2.72 0 BC 2 7.38 0 BD -2 0.14 0 BE 7 1096.63 0.17 CD 5 148.41 0.02 CE 0 1 0 DE 3 20.08 0 ABC 3 20.08 0 ABD 1 2.72 0 ABE 6 403.43 0.06 ACD 8 2980.96 0.45 ACE -1 0.37 0 ADE 4 54.6 0 BCD 1 2.72 0 BCE 6 403.43 0.06 BDE 4 54.6 0 CDE 4 54.6 0 ABCD 4 54.6 0.02 ABCE 5 148.41 0.02 ABDE 5 148.41 0.02 ACDE 5 148.41 0.02 BCDE 5 148.41 0.02 ABCDE 6 403.43 0.06
  29. 29. Energy to probability 4 -2 2 2 -2 -4 1 1 1 12 Hidden Layer Visible Layer E = − ∑ i bivi − ∑ i aihi − ∑ i,j Wijvihj p(v, h) = 1 Z e−E(v,h) Z = ∑ v,h e−E(v,h)
  30. 30. How to train an RBM? What exactly do we want?
  31. 31. 0 0 0 0 0 0 0 0 0 00 A B C D E Scenario Score eScore Probability None 0 1 1/32 A 0 1 1/32 B 0 1 1/32 C 0 1 1/32 D 0 1 1/32 E 0 1 1/32 AB 0 1 1/32 AC 0 1 1/32 AD 0 1 1/32 AE 0 1 1/32 BC 0 1 1/32 BD 0 1 1/32 BE 0 1 1/32 CD 0 1 1/32 CE 0 1 1/32 DE 0 1 1/32 Scenario Score eScore Probability ABC 0 1 1/32 ABD 0 1 1/32 ABE 0 1 1/32 ACD 0 1 1/32 ACE 0 1 1/32 ADE 0 1 1/32 BCD 0 1 1/32 BCE 0 1 1/32 BDE 0 1 1/32 CDE 0 1 1/32 ABCD 0 1 1/32 ABCE 0 1 1/32 ABDE 0 1 1/32 ACDE 0 1 1/32 BCDE 0 1 1/32 ABCDE 0 1 1/32
  32. 32. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE 0 0 0 0 0 0 0 0 0 00 A B C D E
  33. 33. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  34. 34. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  35. 35. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  36. 36. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  37. 37. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  38. 38. How to train an RBM? Contrastive divergence
  39. 39. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE A, C, and no B
  40. 40. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  41. 41. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  42. 42. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE All scenarios
  43. 43. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  44. 44. B and no A,C None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  45. 45. B and no A,C None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  46. 46. B and no A,C None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE All scenarios
  47. 47. B and no A,C None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE All scenarios
  48. 48. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  49. 49. Maximizing the probability of the data 4 -2 2 2 -2 -4 1 1 1 12 Hidden Layer Visible Layer arg max W 𝔼[log P(v)]Maximize ∂ ∂W log P(vn)Derivative: = 𝔼 [ ∂ ∂W − E(v, h)|v = vn] − 𝔼 [ ∂ ∂W − E(v, h) ] arg max W ∏ v∈V P(v) Find
  50. 50. The end? nope…
  51. 51. Small problem
  52. 52. There are way too many possibilities! Problem None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE 32 = 25
  53. 53. How many? … … 100 nodes 200 nodes 2300 configurations
  54. 54. Partition function is intractable 4 -2 2 2 -2 -4 1 1 1 12 Hidden Layer Visible Layer p(v, h) = 1 Z e−E(v,h) Z = ∑ v,h e−E(v,h) Intractable
  55. 55. Problem What can we do? None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  56. 56. Solution: Gibbs sampling
  57. 57. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  58. 58. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  59. 59. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  60. 60. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE All scenarios
  61. 61. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE All scenarios
  62. 62. A, C, and no B None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE All scenarios
  63. 63. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  64. 64. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  65. 65. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  66. 66. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  67. 67. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  68. 68. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  69. 69. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  70. 70. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  71. 71. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  72. 72. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  73. 73. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Aisha Cameron Beto Any other scenario
  74. 74. Aisha Cameron Beto None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Any other scenario
  75. 75. Aisha Cameron Beto None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Any other scenario
  76. 76. Aisha Cameron Beto None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Any other scenario
  77. 77. Aisha Cameron Beto None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Any other scenario
  78. 78. Aisha Cameron Beto None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Any other scenario
  79. 79. Aisha Cameron Beto None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Any other scenario
  80. 80. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE 4 -2 2 2 -2 -4 1 1 1 12 A B C D E
  81. 81. How to increase (or decrease) the probability of a configuration?
  82. 82. A B C ED RBM
  83. 83. A B C ED Increase probability of
  84. 84. A B C ED Increase probability of
  85. 85. Beto CameronAisha Descartes Euler 0 0 0 0 0 0 0 0 0 00 Increase probability of
  86. 86. Beto CameronAisha Descartes Euler 0 0 0 0 0 0 0 0 0 00 Increase probability of Learning rate = 0.1
  87. 87. Beto CameronAisha Descartes Euler 0 0.1 0 0 0.1 0 0.1 0 0.1 0.10 Increase probability of Learning rate = 0.1
  88. 88. Beto CameronAisha Descartes Euler 0 0.1 0 0 0.1 0 0.1 0 0.1 0.10 Decrease probability of
  89. 89. Beto CameronAisha Descartes Euler 0 0.1 0 0 0.1 0 0.1 0 0.1 0.10 Decrease probability of
  90. 90. Beto CameronAisha Descartes Euler 0 0.1 -0.1 0 0.1 0 0.1 0 0 0.1-0.1 Decrease probability of
  91. 91. Beto CameronAisha Descartes Euler 4 -2 2 2 -2 -4 1 1 1 12 None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE
  92. 92. Are we done now? Still no…
  93. 93. Sampling problems
  94. 94. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE A, C, and no B
  95. 95. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE A, C, and no B All other scenarios
  96. 96. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Picking random items from here is really hard! How to pick a random one with conditions How to pick a completely random one
  97. 97. How to pick a sample that agrees with our data point?
  98. 98. Gibbs Sampling
  99. 99. Independent sampling
  100. 100. BetoAisha Descartes 1 1 1 Euler Fernando -2 Gloria -1 Igor 0 2 1 Hypatia 3 Cameron
  101. 101. BetoAisha 1 1 1 Fernando -2 Gloria -1 Igor 0 Descartes Euler2 1 Hypatia 3 Cameron
  102. 102. Beto CameronAisha 1 1 1 Fernando Gloria Igor Hypatia -2 -1 0 3 2 -3 1 -2 P( ) =
  103. 103. Beto CameronAisha 1 1 1 Fernando Gloria Igor Hypatia -2 -1 0 3 2 -3 1 -2P( ) =
  104. 104. Beto CameronAisha 1 1 1 Fernando Gloria Igor Hypatia -2 -1 0 32-31-2P( ) = 1σ( ) = 0.73 σ(x) = 1 1 + e−x 1 1 0.73
  105. 105. Descartes Fernando Euler Hypatia -2 2 1 3 BetoAisha 1 1 1 Gloria Igor-1 0Cameron P( ) =
  106. 106. Descartes Fernando Euler Hypatia -2 2 1 3 -1-1 P( ) =
  107. 107. Descartes Fernando Euler Hypatia -2 2 1 3 -1-1P( ) =
  108. 108. Descartes Fernando Euler Hypatia -2 2 1 3 -1-1P( ) = σ( ) = 0.018 -4
  109. 109. How do we pick random samples?
  110. 110. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE How to pick a random one with conditions How to pick a completely random one
  111. 111. BetoAisha Descartes Euler -0.5 -0.4 0.5 -1 1 0.8 0.5 0.3 10.9 -0.8 Cameron
  112. 112. BetoAisha Descartes -0.4 0.5 1 0.8 0.5 0.3 0.9 Cameron
  113. 113. Aisha Descartes -0.4 0.5 0.9 Cameron -0.4 0.5 0.9 P( ) =
  114. 114. 0.50.9-0.4 Aisha Descartes P( ) = -0.4 0.5 0.9 Cameron = 0.731σ( )
  115. 115. σ( = 0.731 )P( ) = Aisha Euler -1 1 -0.8 σ( = 0.31-0.8 )P( ) = Cameron
  116. 116. BetoAisha Descartes Euler Cameron P = 0.73 P = 0.31
  117. 117. Gibbs Sampling
  118. 118. How to pick a completely random sample?
  119. 119. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE How to pick a random one with conditions How to pick a completely random one
  120. 120. Pick a random spot in the world
  121. 121. None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE Gibbs Sampling How to pick a totally random sample from this distribution
  122. 122. A B C ED A B C ED A B C ED A B C ED A B C ED A B C ED None AC BC DED A D BC DE None DD
  123. 123. A B C ED A B C ED A B C ED A B C ED None BC DE A B C ED AC D D BC DE None D A B C ED A D
  124. 124. A B C ED AC D Increase scores Decrease scores A B C ED A D
  125. 125. Summary
  126. 126. Data None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE ProbabilitiesRestricted Boltzmann Machine 4 -2 2 2 -2 -4 1 1 1 12 A B C D E
  127. 127. Generated Data None A B C D E AB AC AD AE BC BD BE CD CE DE ABC ABD ABE ACD ACE ADE BCD BCE BDE CDE ABCD ABCE ABDE ACDE BCDE ABCDE ProbabilitiesRestricted Boltzmann Machine 4 -2 2 2 -2 -4 1 1 1 12 A B C D E
  128. 128. Visible Layer Hidden Layer Images https://www.pyimagesearch.com/2014/06/23/applying-deep-learning-rbm-mnist-using-python/
  129. 129. Thank you!
  130. 130. Images https://www.freepik.com/free-photos-vectors/people https://www.freepik.com/free-photos-vectors/dog https://www.freepik.com/free-photos-vectors/banner https://www.freepik.com/free-photos-vectors/background https://www.freepik.com/free-photos-vectors/background
  131. 131. This presentation was done on Keynote
  132. 132. https://www.manning.com/books/grokking-machine-learning Discount code: serranoyt Grokking Machine Learning By Luis G. Serrano
  133. 133. Links @luis_likes_math Subscribe, like, share, comment! youtube.com/c/LuisSerrano http://serrano.academy

Slides for this video https://www.youtube.com/watch?v=Fkw0_aAtwIw

Views

Total views

104

On Slideshare

0

From embeds

0

Number of embeds

0

Actions

Downloads

25

Shares

0

Comments

0

Likes

0

×