Deep Generative Models Overview
Deep Generative Models Overview
A symmetric network:
𝑤!" = 𝑤"!
• If the sign of the field at any neuron opposes its own sign, it
“flips” to match the field
• Which will change the field at other nodes
• Which may then flip
• Which may cause other neurons including the first one to flip…
• And so on…
• If the sign of the field at any neuron opposes its own sign, it
“flips” to match the field
• Which will change the field at other nodes
• Which may then flip
• Which may cause other neurons including the first one to flip…
+1 𝑖𝑓 𝑧 > 0
Θ 𝑧 =)
−1 𝑖𝑓 𝑧 ≤ 0
• Let 𝑦!" be the output of the i-th neuron just before it responds to the current field
• Let 𝑦!# be the output of the i-th neuron just after it responds to the current field
• If 𝑦!" = 𝑠𝑖𝑔𝑛 ∑$%! 𝑤$! 𝑦$ + 𝑏! , then 𝑦!# = 𝑦!"
• If the sign of the field matches its own sign, it does not flip
+1 𝑖𝑓 𝑧 > 0
Θ 𝑧 =)
−1 𝑖𝑓 𝑧 ≤ 0
• If 𝑦!" ≠ 𝑠𝑖𝑔𝑛 ∑#$! 𝑤#! 𝑦# + 𝑏! , then 𝑦!% = −𝑦!"
= % 𝑤!" 𝑦! 𝑦" + % 𝑏! 𝑦!
!,"#! !
• Assume 𝑤!! = 0
𝐷 = 0 𝑤!# 𝑦! 𝑦# + 0 𝑏! 𝑦!
!,#$! !
• 𝐷 is bounded
𝐷'() = 0 𝑤!# + 0 𝑏!
!,#$! !
𝐸 = − $ 𝑤!" 𝑦! 𝑦" − $ 𝑏! 𝑦!
!,"#! !
• Just the negative of 𝐷
PE
state
PE
state
• Each of the minima is a “stored” pattern
• If the network is initialized close to a stored pattern, it will inevitably evolve to
the pattern
• This is a content addressable memory
• Recall memory content from partial or corrupt values
• Also called associative memory
Deep Generative Models CS504 - Artificial Neural Networks 19
Evolution
𝐸 = − $ 𝑤!" 𝑦! 𝑦"
!,"*!
𝑦! = Θ 0 𝑤#! 𝑦# + 𝑏!
#$!
• [Link]
Deep Generative Models CS504 - Artificial Neural Networks 22
Computational algorithm
1. Initialize network with initial pattern
𝑦! 0 = 𝑥! , 0≤𝑖 ≤𝑁−1
-1 1 1 -1
1 -1 -1 1
𝐸 = − 8 8 𝑤"! 𝑦" 𝑦!
! "$!
Deep Generative Models CS504 - Artificial Neural Networks 26
A network can store multiple patterns
-1
1 -1
PE
-1 1
state 1 -1
1 -1 1 -1
𝐸 = − $ $ 𝑤"! 𝑦" 𝑦!
! "*!
-1 1 1 -1
1 -1
-1 1
1 -1
HEBBIAN LEARNING:
𝑤'( = 𝑦' 𝑦(
-1 1
1 -1
HEBBIAN LEARNING:
𝑤'( = 𝑦' 𝑦(
-1 1
= − $ $ 1 = −0.5𝑁(𝑁 − 1)
! "*!
• This is the lowest possible energy value for the network
Deep Generative Models CS504 - Artificial Neural Networks 31
Hebbian learning: Storing a 4-bit pattern
1 -1 1 -1
-1 1 1 -1
Energy
state
• Parasitic patterns can occur because sums of odd numbers of stored
patterns are also stable for Hebbian learning:
• 𝐲&'(')!*+ = 𝑠𝑖𝑔𝑛 𝐲' + 𝐲, + 𝐲-
• They are also from other random local energy minima from the
weights matrices themselves
Deep Generative Models CS504 - Artificial Neural Networks 35
Alternate Approach to Estimating the
Network
1 +
𝐸(𝐲) = − 𝐲 𝐖𝐲 − 𝐛+ 𝐲
2
𝐖 = 𝐖 + 𝜂 $ 𝐲𝐲 + − $ 𝐲𝐲 +
𝐲∈𝐘" 𝐲∉𝐘"
𝐖 = 𝐖 + 𝜂 $ 𝐲𝐲 + − $ 𝐲𝐲 +
𝐲∈𝐘" 𝐲∉𝐘"
𝐖 = 𝐖 + 𝜂 $ 𝐲𝐲 + − $ 𝐲𝐲 +
𝐲∈𝐘" 𝐲∉𝐘"
Energy
Energy
Energy
Energy
Energy
• Initialize 𝐖
• Compute the total outer product of all target patterns
• More important patterns presented more frequently
• Randomly initialize the network several times and let it evolve
• And settle at a valley
• Compute the total outer product of valley patterns
• Update weights
Energy
Energy
• Initialize 𝐖
• Compute the total outer product of all target patterns
• More important patterns presented more frequently
• Initialize the network with each target pattern and let it evolve
• And settle at a valley
• Compute the total outer product of valley patterns
• Update weights
1 +
𝐸(𝐲) = − 𝐲 𝐖𝐲 𝑃(𝐲) = 𝐶𝑒𝑥𝑝 −𝐸(𝐲)
2
𝐖 = 𝐖 + 𝜂 $ 𝛼𝐲 𝐲𝐲 + − $ 𝛽 𝐸(𝐲) 𝐲𝐲 +
𝐲∈𝐘" 𝐲∉𝐘"
𝐖 = 𝐖 + 𝜂 $ 𝛼𝐲 𝐲𝐲 + − $ 𝛽 𝐸(𝐲) 𝐲𝐲 +
𝐲∈𝐘" 𝐲∉𝐘"
𝐖 = 𝐖 + 𝜂 $ 𝛼𝐲 𝐲𝐲 + − $ 𝛽 𝐸(𝐲) 𝐲𝐲 +
𝐲∈𝐘" 𝐲∉𝐘"
𝐖 = 𝐖 + 𝜂 𝐸𝐲~𝐘" 𝐲𝐲 + − 𝐸𝐲~O 𝐲𝐲 +
Natural distribution for variables: The Boltzmann Distribution
𝑒𝑥𝑝 −𝐸(𝑆)
𝑃 𝑆 =
∑BC 𝑒𝑥𝑝 −𝐸(𝑆′)
𝑒𝑥𝑝 −𝐸(𝑆)
𝑃 𝑆 =
∑BC 𝑒𝑥𝑝 −𝐸(𝑆′)
𝑃 𝑆 = 𝑃 𝑠! = 1 𝑠"#! 𝑃(𝑠"#! )
𝑃 𝑆′ = 𝑃 𝑠! = −1 𝑠"#! 𝑃(𝑠"#! )
𝑃 𝑠! = 1 𝑠"#!
log 𝑃 𝑆 − log 𝑃 𝑆( = log
1 − 𝑃 𝑠! = 1 𝑠"#!
1
𝑃(𝑠! = 1|𝑠"#! ) =
1 + 𝑒 8D!
1
𝑃(𝑠! = 1|𝑠"#! ) =
1 + 𝑒 8D!
1
𝑃(𝑠! = 1|𝑠"#! ) =
1 + 𝑒 8D!
1
= 8 8 𝑤!" 𝑠! 𝑠" − log 8 𝑒𝑥𝑝 8 𝑤!" 𝑠!( 𝑠"(
𝑁
) !$" )( !$"
𝑑ℒ 1
= 8 𝑠! 𝑠" −? ? ?
𝑑𝑤!" 𝑁
)
• The second term is simply the expected value of sisj, over all
possible values of the state
• We cannot compute it exhaustively, but we can compute it by
sampling!
1
% 𝑃(𝑆 C )𝑠!C 𝑠"C ≈ % 𝑠!C 𝑠"C
𝑀
BC BC∈𝐒"#$%&'"
𝑑 log 𝑃 𝐒 1 1
= 8 𝑠! 𝑠" − 8 𝑠!( 𝑠"(
𝑑𝑤!" 𝑁 𝑀
) )(∈𝐒!"#$%
𝑑 log 𝑃 𝐒
𝑤!" = 𝑤!" + 𝜂
𝑑𝑤!"
• Terminology:
• The neurons that store the actual patterns of interest: Visible neurons
• The neurons that only serve to increase the capacity but whose actual values
are not important: Hidden neurons
• These can be set to anything in order to store a visible pattern
• For a given pattern of visible neurons, there are any number of hidden
patterns (2K)
• Which of these do we choose?
• Ideally choose the one that results in the lowest energy
• But that’s an exponential search space!
Deep Generative Models CS504 - Artificial Neural Networks 75
The patterns
• In fact we could have multiple hidden patterns coupled with any
visible pattern
• These would be multiple stored patterns that all give the same visible
output
• How many do we permit
• Now, with hidden neurons the complete state pattern for even
the training patterns is unknown
• Since they are only defined over visible neurons
𝑃 𝑆 = 𝑃(𝑉, 𝐻)
𝑃 𝑉 = % 𝑃(𝑆)
G
• We are interested in the marginal probabilities over visible bits
• We want to learn to represent the visible bits
• The hidden bits are the “latent” representation learned by the network
• 𝑆 = (𝑉, 𝐻)
• 𝑉 = visible bits
• 𝐻 = hidden bits
Deep Generative Models CS504 - Artificial Neural Networks 78
Training the network 𝐸 𝑆 = − % 𝑤!" 𝑠! 𝑠"
Visible
!A"
Neurons
𝑒𝑥𝑝 ∑!A" 𝑤!" 𝑠! 𝑠"
𝑃 𝑆 =
∑BC 𝑒𝑥𝑝 ∑!A" 𝑤!" 𝑠!C 𝑠"C
1
= 8 log 8 𝑒𝑥𝑝 8 𝑤!" 𝑠! 𝑠" − log 8 𝑒𝑥𝑝 8 𝑤!" 𝑠!( 𝑠"(
𝑁
1∈𝐕 0 !$" )( !$"
• Maximize the average log likelihood of all visible bits of “training” vectors 𝐕 =
{𝑉1, 𝑉2, … , 𝑉𝑁}
• The first term also has the same format as the second term
• Log of a sum
• Derivatives of the first term will have the same form as for the second term
( (
𝑑ℒ 1 𝑒𝑥𝑝 ∑!$" 𝑤!" 𝑠! 𝑠" ( (
𝑒𝑥𝑝 ∑ !$" 𝑤!" 𝑠! 𝑠" ( (
= 88 " "
𝑠! 𝑠" − 8 " "
𝑠! 𝑠"
𝑑𝑤!" 𝑁 ∑0" 𝑒𝑥𝑝 ∑!$" 𝑤!" 𝑠! 𝑠" ∑)" 𝑒𝑥𝑝 ∑!$" 𝑤!" 𝑠! 𝑠"
1∈𝐕 0 )(
𝑑ℒ 1
= 8 8 𝑃 𝑆|𝑉 𝑠! 𝑠" − 8 𝑃(𝑆 ( )𝑠!( 𝑠"(
𝑑𝑤!" 𝑁
1∈𝐕 0 )(
• We’ve derived this math earlier
• But now both terms require summing over an exponential number of states
• The first term fixes visible bits, and sums over all configurations of hidden states for each visible
configuration in our training set
• But the second term is summed over all states
• Now unclamp the visible units and let the entire network evolve
several times to generate
𝐒Y!deJ = {𝑆Y!deJ,% , 𝑆Y!deJ,%G< , … , 𝑆Y!deJ,f }
𝑑 log 𝑃 𝐒
𝑤!" = 𝑤!" − 𝜂
𝑑𝑤!"
• Initialize weights
• Run simulations to get clamped and unclamped training samples
• Compute gradient and update weights
• Iterate
VISIBLE
• Partition visible and hidden units
• Visible units ONLY talk to hidden units
• Hidden units ONLY talk to visible units
• Restricted Boltzmann machine..
• Originally proposed as “Harmonium Models” by Paul Smolensky
VISIBLE
𝑧! = % 𝑤"! 𝑠! + 𝑏! 1
𝑃(𝑠! = 1) =
" 1 + 𝑒 8D!
• Still obeys the same rules as a regular Boltzmann machine
• But the modified structure adds a big benefit..
Deep Generative Models CS504 - Artificial Neural Networks 87
Solution: Restricted Boltzmann Machines
HIDDEN
VISIBLE
𝑧! = % 𝑤"! 𝑣! + 𝑏! 1
HIDDEN 𝑃(ℎ! = 1) =
" 1 + 𝑒 8D!
𝑦! = % 𝑤"! ℎ! + 𝑏! 1
VISIBLE 𝑃(𝑣! = 1) =
" 1 + 𝑒 8H!
Deep Generative Models CS504 - Artificial Neural Networks 88
Sampling: Restricted Boltzmann machine
𝑧! = 8 𝑤"! 𝑣! + 𝑏!
HIDDEN "
1
𝑃(ℎ! = 1) =
1 + 𝑒 45"
VISIBLE
VISIBLE
𝑧! = % 𝑤"! 𝑣! + 𝑏! 𝑦! = % 𝑤"! ℎ! + 𝑏!
" "
1 1
𝑃(ℎ! = 1) = 𝑃(𝑣! = 1) =
1 + 𝑒 8D! 1 + 𝑒 8H!
• For each sample:
• Iteratively sample hidden and visible units for a long time
• Draw final sample of both hidden and visible units
Deep Generative Models CS504 - Artificial Neural Networks 90
Pictorial hrepresentation
h h
of RBM training
h
0 1 2 ∞
v0 v1 v2 v∞
• For each sample:
• Initialize 𝑉I (visible) to training instance value
• Iteratively generate hidden and visible units
• For a very long time
i v0 i v1 i v2 i v∞
• Gradient (showing only one edge from visible node i to hidden node
j)
¶ log p(v) 0 ¥
= <vi h j > - <vi h j >
¶wij
• <vi, hj> represents average over many generated training samples
i v0 i v1
• Sufficient to run one iteration!
¶ log p (v)
= <vi h j > 0 - <vi h j >1
¶wij
VISIBLE
𝑧! = % 𝑤"! 𝑣! + 𝑏! 1
HIDDEN 𝑃(ℎ! = 1) =
" 1 + 𝑒 8D!