Intuition Behind Restricted Boltzmann Machine (RBM)


15

Ho seguito il corso sulle reti neurali di Geoff Hinton su Coursera e anche attraverso l' introduzione alle macchine boltzmann riservate , ma non capivo l'intuizione dietro gli RBM.

Perché dobbiamo calcolare l'energia in questa macchina? E a che serve la probabilità in questa macchina? Ho visto anche questo video . Nel video, ha appena scritto le equazioni di probabilità ed energia prima delle fasi di calcolo e non sembra usarlo da nessuna parte.

In aggiunta a quanto sopra, non sono sicuro a cosa serva la funzione di probabilità?


Ho cercato di riordinare la domanda, ma penso che abbia bisogno di più lavoro. È necessario spiegare che cosa fai capire, e più specificamente in cui si sono bloccati, altrimenti la domanda è troppo ampia.
Neil Slater,

L'unica cosa che è entrata nella testa è che ci sono tre fasi, prima la fase positiva, quindi la fase negativa che è seguita dalla ricostruzione dei pesi. Ma che dire delle funzioni di energia e probabilità? a che serve qui? e quante volte dobbiamo eseguire questo processo (fase positiva -> fase negativa> ricostruzione dei pesi)?
Born2Code

Risposte:


5

Gli RBM sono una bestia interessante. Per rispondere alla tua domanda e fare jogging sulla mia memoria, trarrò gli RBM e parlerò attraverso la derivazione. Hai detto che sei confuso sulla probabilità, quindi la mia derivazione sarà dal punto di vista del tentativo di massimizzare la probabilità. Quindi cominciamo.

Gli RBM contengono due diversi insiemi di neuroni, visibili e nascosti, li indicherò rispettivamente e h . Data una configurazione specifica di v e h , lo mappiamo lo spazio di probabilità.vhvh

p(v,h)=eE(v,h)Z

Ci sono un paio di cose in più da definire. La funzione surrogata che utilizziamo per mappare da una configurazione specifica allo spazio di probabilità è chiamata funzione energetica . La costante Z è un fattore di normalizzazione per garantire che effettivamente mappiamo allo spazio di probabilità. Ora andiamo a quello che stiamo davvero cercando; la probabilità di un insieme di neuroni visibili, in altre parole, la probabilità dei nostri dati. Z = v V h H e - E ( v , h ) p ( v )E(v,h)Z

Z=vVhHeE(v,h)
p(v)=hHp(v,h)=hHeE(v,h)vVhHeE(v,h)

Sebbene ci siano molti termini in questa equazione, si riduce semplicemente a scrivere le equazioni di probabilità corrette. Speriamo che, finora, questo ha aiutato a capire il motivo per cui abbiamo bisogno funzione energia per calcolare la probabilità, o ciò che viene fatto più spesso il non normalizzato probabilità . La probabilità non normalizzata viene utilizzata perché la funzione di partizione Zp(v)ZZ è molto costosa da calcolare.

Ora passiamo alla fase di apprendimento effettiva degli RBM. Per massimizzare la probabilità, per ogni punto dati, dobbiamo fare un gradiente per rendere . Per ottenere le espressioni gradiente ci vogliono alcune acrobazie matematiche. La prima cosa che facciamo è prendere il registro di p ( v ) . D'ora in poi opereremo nello spazio delle probabilità dei log per rendere fattibile la matematica.p(v)=1p(v)

Prendiamo il gradiente rispetto a i paremeters in p ( v )

log(p(v))=log[hHeE(v,h)]log[vVhHeE(v,h)]
p(v)

log(p(v))θ=1hHeE(v,h)hHeE(v,h)E(v,h)θ+1vVhHeE(v,h)vVhHeE(v,h)E(v,h)θ

Ora l'ho fatto su carta e ho scritto l'equazione semifinale per non perdere molto spazio su questo sito. Ti consiglio di derivare queste equazioni da solo. Ora scriverò alcune equazioni che aiuteranno a continuare la nostra derivazione. Nota che: , p ( v ) = h H p ( v , h ) e che p ( h | v ) =Zp(v,h)=eE(v,h)p(v)=hHp(v,h)p(h|v)=p(v,h)p(h)

log(p(v))θ=1p(v)hHp(v,h)E(v,h)θ+vVhHp(v,h)E(v,h)θlog(p(v))θ=hHp(h|v)E(v,h)θ+vVhHp(v,h)E(v,h)θ

And there we go, we derived maximum likelihood estimation for RBM's, if you want you can write the last two terms via expectation of their respective terms (conditional, and joint probability).

Notes on energy function and stochasticity of neurons.

As you can see above in my derivation, I left the definition of the energy function rather vague. And the reason for doing that is that many different versions of RBM implement various energy functions. The one that Hinton describes in the lecture linked above, and shown by @Laurens-Meeus is:

E(v,h)=aTvbThvTWh.

It might be easier to reason about the gradient terms above via the expectation form.

log(p(v))θ=Ep(h|v)E(v,h)θ+Ep(v,h)E(v,h)θ

The expectation of the first term is actually really easy to calculate, and that was the genius behind RBMs. By restricting the connection the conditional expectation simply becomes a forward propagation of the RBM with the visible units clamped. This is the so called wake phase in Boltzmann machines. Now calculating the second term is much harder and usually Monte Carlo methods are utilized to do so. Writing the gradient via average of Monte Carlo runs:

log(p(v))θE(v,h)θp(h|v)+E(v,h)θp(v,h)

Calculating the first term is not hard, as stated above, therefore Monte-Carlo is done over the second term. Monte Carlo methods use random successive sampling of the distribution, to calculate the expectation (sum or integral). Now this random sampling in classical RBM's is defined as setting a unit to be either 0 or 1 based on its probability stochasticly, in other words, get a random uniform number, if it is less than the neurons probability set it to 1, if it is greater than set it to 0.


How do we make hidden layer binary too? Bcoz after the activation function operation, we would be getting values in the range between 0 and 1.
Born2Code

This is usually done by thresholding the activation. Anything above 0.5, would become 1, anything below would be zero.
Armen Aghajanyan

But in this link , in section 3.1: Hinton has stated "the hidden unit turns on if this probability is greater than a random number uniformly distributed between 0 and 1". What does this actually mean? And also in this link, they say "Then the jth unit is on if upon choosing s uniformly distributed random number between 0 and 1 we find that its value is less than sig[j]. Otherwise it is off." I didn't get this.
Born2Code

????? How to say whether that particular unit is turned on or off?
Born2Code

I've added an edit. I suggest reading up on Monte Carlo methods because the stochasticity of this algorithm is derived from there.
Armen Aghajanyan

5

In addition to the existing answers, I would like to talk about this energy function, and the intuition behind that a bit. Sorry if this is a bit long and physical.

The energy function describes a so-called Ising model, which is a model of ferromagnetism in terms of statistical mechanics / quantum mechanics. In statistical mechanics, we use a so-called Hamiltonian operator to describe the energy of a quantum-mechanical system. And a system always tries to be in the state with the lowest energy.

Now, the Ising model basically describes the interaction between electrons with a spin σk of either +1 or -1, in presence of an external magnetic field h. The interaction between two electrons i and j is described by a coefficient Jij. This Hamiltonian (or energy function) is

H^=i,jJijσiσjμjhjσj
where H^ denotes the Hamiltonian. A standard procedure to get from an energy function to the probability, that a system is in a given state (i.e. here: a configuration of spins, e.g. σ1=+1,σ2=1,...) is to use the Boltzmann distribution, which says that at a temperature T, the probability pi of the system to be in a state i with energy Ei is given by
pi=exp(Ei/kT)iexp(Ei/kt)
At this point, you should recognize that these two equations are the exact same equations as in the videos by Hinton and the answer by Armen Aghajanyan. This leads us to the question:

What does the RBM have to do with this quantum-mechanical model of ferromagnetism?

We need to use a final physical quantity: the entropy. As we know from thermodynamics, a system will settle in the state with the minimal energy, which also corresponds to the state with the maximal entropy.

As introduced by Shanon in 1946, in information theory, the entropy H can also be seen as a measure of the information content in X, given by the following sum over all possible states of X:

H(X)=iP(xi)logP(xi)
Now, the most efficient way to encode the information content in X, is to use a way that maximizes the entropy H.

Finally, this is where we get back to RBMs: Basically, we want this RBM to encode as much information as possible. So, as we have to maximize the (information-theoretical) entropy in our RBM-System. As proposed by Hopfield in 1982, we can maximize the information-theoretical entropy exactly like the physical entropy: by modelling the RBM like the Ising model above, and use the same methods to minimize the energy. And that is why we need this strange energy function for in an RBM!

The nice mathematical derivation in Armen Aghajanyan's answer shows everything we need to do, to minimize the energy, thus maximizing entropy and storing / saving as much information as possible in our RBM.

PS: Please, dear physicists, forgive any inaccuracies in this engineer's derivation. Feel free to comment on or fix inaccuracies (or even mistakes).


I saw this video, Just watch the video from that point. how do you get that sampled number? whether we have just run rand() in matlab and obtain it? and then it would be different for each h(i) . Oh nooo! I don't think machine will learn properly.
Born2Code

@Born2Code this is another question. Can you post it as a new question to this site? Please try to add the equations you are talking about to the new question, and explain what parts you don't understand.
hbaderts


0

The answer of @Armen has gave myself a lot of insights. One question hasn't been answered however.

The goal is to maximize the probability (or likelihood) of the v. This is correlated to minimizing the energy function related to v and h:

E(v,h)=aTvbThvTWh

Our variables are a, b and W, which have to be trained. I'm quite sure this training will be the ultimate goal of the RBM.


How do we make hidden layer binary too? Bcoz after the activation function operation, we would be getting values in the range between 0 and 1.
Born2Code

@Born2Code: The activation function gives you the probability that a neuron has value 1. Therefore to "make it binary", you sample from the probabilities calculated for either h or v - in other words you literally do something like h_bin = (rand() < h_val) ? 1 : 0 - this has to be done for each neuron, and each time you want a sample.
Neil Slater

@NeilSlater: but why a random number? Also, whether the random should be generated for each iteration or the same number should be used for all the iterations? one more serious doubt, how many iterations have to be done? I have a training set V, which has only one vector, i.e. v1. With v1, how many times should I have to iterate?
Born2Code

@NeilSlater: One more doubt is, whether the same random number is to be compared with all the values of hidden layer? I know this is such an idiotic question but still
Born2Code

1
It's a random number because that is how you resolve probabilities to binary values. It is a dIfferent number for each neuron inside h or v - you are sampling a vector of binary values for h or v, in order to generate an example that the network "believes" exists - i.e. an example that has a high statistical chance of being representative of the training set. During training, you determine how well it matches an existing training example and adjust weights accordingly.
Neil Slater
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.