Started adding material about Boltzmann Machines

This commit is contained in:
mhjensen
2018-03-24 12:48:20 -04:00
parent b38220590e
commit 85078d88c2
7 changed files with 345 additions and 23 deletions
+136
View File
@@ -0,0 +1,136 @@
TITLE: Data Analysis and Machine Learning: Unsupervised Learning and Boltzmann Machines
AUTHOR: Morten Hjorth-Jensen {copyright, 1999-present|CC BY-NC} at Department of Physics, University of Oslo & Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
DATE: today
!split
===== What is Unsupervised Learning? =====
The idea of representing the wave function in quantum mechanics with
a restricted Boltzmann machine (RBM) was presented recently by "G. Carleo and M. Troyer, Science _355_, Issue 6325, pp. 602-606 (2017)":"http://science.sciencemag.org/content/355/6325/602". They
named such a wave function/network a \textit{neural network quantum
state} (NQS). In their article they apply it to the quantum mechanical
spin lattice systems of the Ising model and Heisenberg model, with
encouraging results.
=== Representing the wave function with a neural network ===
Our neural network of choice is the restricted Boltzmann machine. It
is a two layer net where one is called the layer of visible nodes and
the other the layer of hidden nodes. It is called restricted because
there are no connections between nodes in the same layer. Meaning
there's only a connection between two nodes if one is visible and the
other hidden. These type of networks constitute the building blocks of
the deep belief networks. The RBM is a
generative network, meaning that the idea is for it to learn a
\textit{probability distribution}. Thus the network does not produce
an output directly, but a probability distribution from which we can
generate an output. In our case this distribution corresponds to the
wave function and the output we wish to generate are the positions
taken by the particles in our system.
Neural networks are referred to as falling
under either supervised or unsupervised learning. Here we are not
working with training data, thus it is not supervised. It's rather
called reinforcement learning. From the variational principle we know
that the NQS wave fucntion represents the ground state once the
quantum mechanical energy is minimized. This information is used to
optimize the weights and biases of the network.
For more information and practical guides to the RBM, check out the links in the literature section.
When working with the restricted Boltzmann machine we are given the joint probability distribution between the hidden and visible nodes.
=== Restricted Boltzmann Machine (RBM) ===
The joint probability distribution is defined as
!bt
\begin{align}
F_{rbm}(\mathbf{X},\mathbf{H}) = \frac{1}{Z} e^{-\frac{1}{T_0}E(\mathbf{X},\mathbf{H})}
\end{align}
!et
where $Z$ is the partition function/normalization constant
!bt
\begin{align}
Z = \int \int \frac{1}{Z} e^{-\frac{1}{T_0}E(\mathbf{x},\mathbf{h})} d\mathbf{x} d\mathbf{h}
\end{align}
!et
It is common to ignore $T_0$ by setting it to one. Here $E$ is known
as the energy of a configuration of the nodes. Do not confuse this
with the energy of the quantum mechanical system. Here it is a
function which gives the specifics of the relation between the hidden
and visible nodes. Different versions of RBMs will implement the
energy function differently.
=== Gaussian-Binary RBM ===
The original and most common version of an RBM is called "binary-binary", meaning both visible and hidden nodes only take on binary values. In our case we wish to model continuous values (positions), thus the visible nodes should be continuous. We therefore choose an RBM called "Gaussian-binary".
!bt
\begin{align}
E(\mathbf{X}, \mathbf{H}) = \sum_i^M \frac{(X_i - a_i)^2}{2\sigma_i^2} - \sum_j^N b_j H_j - \sum_{i,j}^{M,N} \frac{X_i w_{ij} H_j}{\sigma_i^2}
\end{align}
!et
If $\sigma_i = \sigma$ then
!bt
\begin{align}
E(\mathbf{X}, \mathbf{H})= \frac{||\mathbf{X} - \mathbf{a}||^2}{2\sigma^2} - \mathbf{b}^T \mathbf{H} - \frac{\mathbf{X}^T \mathbf{W} \mathbf{H}}{\sigma^2}
\end{align}
!et
Here $\mathbf{X}$ are the visible nodes (the position coordinates), $\mathbf{H}$ are the hidden nodes, $\mathbf{a}$ are the visible biases, $\mathbf{b}$ are the hidden biases and $\mathbf{W}$ is a matrix containing the weights characterizing the connection of each visible node to a hidden node.
=== The Wave Function ===
To find the marginal probability $F_{rbm}(X)$ we set:
!bt
\begin{align}
F_{rbm}(\mathbf{X}) &= \sum_\mathbf{h} F_{rbm}(\mathbf{X}, \mathbf{h}) \\
&= \frac{1}{Z}\sum_\mathbf{h} e^{-E(\mathbf{X}, \mathbf{h})}
\end{align}
!et
This is used to represent the wave function:
!bt
\begin{align}
\Psi (\mathbf{X}) &= F_{rbm}(\mathbf{X}) \\
&= \frac{1}{Z}\sum_{\{h_j\}} e^{-E(\mathbf{X}, \mathbf{h})} \\
&= \frac{1}{Z} \sum_{\{h_j\}} e^{-\sum_i^M \frac{(X_i - a_i)^2}{2\sigma^2} + \sum_j^N b_j h_j + \sum_{i,j}^{M,N} \frac{X_i w_{ij} h_j}{\sigma^2}} \\
&= \frac{1}{Z} e^{-\sum_i^M \frac{(X_i - a_i)^2}{2\sigma^2}} \prod_j^N (1 + e^{b_j + \sum_i^M \frac{X_i w_{ij}}{\sigma^2}}) \\
\end{align}
!et
=== The Monte Carlo procedure ===
In many aspects, the procedure of optimizing the NQS wave function
will be very similar to the VMC method in project one. However, it
requires a heavier emphasis on the minimization process. Whereas in
project one you only had one or two parameters to optimize and could
even determine them analytically, in this situation the biases and
weights quickly add up to a high number of parameters to optimize, and
it's hard, if possible at all, to determine them analytically. Thus
minimizing the quantum mechanical energy and optimizing the parameters
is important from the beginning. Still, the structure of the process
is similar. You set up an initial guess of the NQS wave function by
giving the weights and biases random, preferably small values. The
process then follows the same structure as the VMC method.
@@ -0,0 +1,12 @@
\mode<presentation>
\usecolortheme[rgb={0.8, 0.2, 0}]{structure}
\usefonttheme[onlysmall]{structurebold}
\setbeamertemplate{navigation symbols}{}
%\setbeamertemplate{footline}[frame number]
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,backgrounds,decorations,mindmap}
\mode
<all>
@@ -0,0 +1,15 @@
\mode<presentation>
\useoutertheme{smoothbars}
\useinnertheme[shadow=true]{rounded}
\usecolortheme{orchid}
\usecolortheme{whale}
\usecolortheme[rgb={0.7, 0.2, 0}]{structure} % (darker red)
\useoutertheme{shadow}
\usefonttheme[onlysmall]{structurebold}
\setbeamercolor{title}{use=structure,fg=white,bg=structure.fg}
\setbeamerfont{block title}{size={}}
\mode
<all>
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
doconce clean
rm -rf *.pdf *.tex ipynb*.tar.gz *.html ._*.html *~ reveal.js Trash README.txt
+118
View File
@@ -0,0 +1,118 @@
v#!/bin/sh
set -x
function system {
"$@"
if [ $? -ne 0 ]; then
echo "make.sh: unsuccessful command $@"
echo "abort!"
exit 1
fi
}
if [ $# -eq 0 ]; then
echo 'bash make.sh slides1|slides2'
exit 1
fi
name=$1
rm -f *.tar.gz
opt="--encoding=utf-8"
# Note: Makefile examples contain constructions like ${PROG} which
# looks like Mako constructions, but they are not. Use --no_mako
# to turn off Mako processing.
opt="--no_mako"
rm -f *.aux
html=${name}-reveal
system doconce format html $name --pygments_html_style=perldoc --keep_pygments_html_bg --html_links_in_new_window --html_output=$html $opt
system doconce slides_html $html reveal --html_slide_theme=beige
# Plain HTML documents
html=${name}-solarized
system doconce format html $name --pygments_html_style=perldoc --html_style=solarized3 --html_links_in_new_window --html_output=$html $opt
system doconce split_html $html.html --method=space10
html=${name}
system doconce format html $name --pygments_html_style=default --html_style=bloodish --html_links_in_new_window --html_output=$html $opt
system doconce split_html $html.html --method=space10
# Bootstrap style
html=${name}-bs
system doconce format html $name --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=$html $opt
#system doconce split_html $html.html --method=split --pagination --nav_button=bottom
# IPython notebook
system doconce format ipynb $name $opt
# LaTeX Beamer slides
beamertheme=red_plain
system doconce format pdflatex $name --latex_title_layout=beamer --latex_table_format=footnotesize $opt
system doconce ptex2tex $name envir=minted
# Add special packages
doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex
system doconce slides_beamer $name --beamer_slide_theme=$beamertheme
system pdflatex -shell-escape ${name}
system pdflatex -shell-escape ${name}
cp $name.pdf ${name}-beamer.pdf
cp $name.tex ${name}-beamer.tex
# Handouts
system doconce format pdflatex $name --latex_title_layout=beamer --latex_table_format=footnotesize $opt
system doconce ptex2tex $name envir=minted
# Add special packages
doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex
system doconce slides_beamer $name --beamer_slide_theme=red_shadow --handout
system pdflatex -shell-escape $name
pdflatex -shell-escape $name
pdflatex -shell-escape $name
pdfnup --nup 2x3 --frame true --delta "1cm 1cm" --scale 0.9 --outfile ${name}-beamer-handouts2x3.pdf ${name}.pdf
rm -f ${name}.pdf
# Ordinary plain LaTeX document
rm -f *.aux # important after beamer
system doconce format pdflatex $name --minted_latex_style=trac --latex_admon=paragraph $opt
system doconce ptex2tex $name envir=minted
# Add special packages
doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex
doconce replace 'section{' 'section*{' $name.tex
pdflatex -shell-escape $name
pdflatex -shell-escape $name
mv -f $name.pdf ${name}-minted.pdf
cp $name.tex ${name}-plain-minted.tex
# Publish
dest=../../pub
if [ ! -d $dest/$name ]; then
mkdir $dest/$name
mkdir $dest/$name/pdf
mkdir $dest/$name/html
mkdir $dest/$name/ipynb
fi
cp ${name}*.pdf $dest/$name/pdf
cp -r ${name}*.html ._${name}*.html reveal.js $dest/$name/html
# Figures: cannot just copy link, need to physically copy the files
if [ -d fig-${name} ]; then
if [ ! -d $dest/$name/html/fig-$name ]; then
mkdir $dest/$name/html/fig-$name
fi
cp -r fig-${name}/* $dest/$name/html/fig-$name
fi
cp ${name}.ipynb $dest/$name/ipynb
ipynb_tarfile=ipynb-${name}-src.tar.gz
if [ ! -f ${ipynb_tarfile} ]; then
cat > README.txt <<EOF
This IPython notebook ${name}.ipynb does not require any additional
programs.
EOF
tar czf ${ipynb_tarfile} README.txt
fi
cp ${ipynb_tarfile} $dest/$name/ipynb
+2 -1
View File
@@ -10,7 +10,7 @@ AUTHOR: "Morten Hjorth-Jensen":"http://mhjgit.github.io/info/doc/web/" at Depart
<%
pub_url = 'https://compphysics.github.io/MachineLearning/doc/pub'
published = ['How2ReadData', 'Linalg', 'Statistics', 'Regression', 'Splines', 'NeuralNet', 'Bayesian', 'DecisionTrees', 'svm', ]
published = ['How2ReadData', 'Linalg', 'Statistics', 'Regression', 'Splines', 'NeuralNet', 'Bayesian', 'DecisionTrees', 'svm', 'BM',]
chapters = {
'How2ReadData': 'Introduction and handling of data',
'Linalg': 'Review of central linear algebra elements',
@@ -21,6 +21,7 @@ chapters = {
'Bayesian': 'Elements of Bayesian theory',
'DecisionTrees': 'Decision trees, from simple to random ones',
'svm': 'Support Vector Machines',
'BM': 'Unsupervised Learning, Boltzmann Machines',
}
%>
+59 -22
View File
@@ -83,24 +83,25 @@ div { text-align: justify; text-justify: inter-word; }
None,
'___sec7'),
('Support Vector Machines', 2, None, '___sec8'),
('Python and Scikit Learn, a short guide', 2, None, '___sec9'),
('Teach yourself C++', 2, None, '___sec10'),
('Projects Fall 2017', 2, None, '___sec11'),
('Project', 3, None, '___sec12'),
('Course content', 3, None, '___sec13'),
('Learning outcomes', 2, None, '___sec14'),
('Prerequisites', 2, None, '___sec15'),
('The course has two central parts', 2, None, '___sec16'),
('Unsupervised Learning, Boltzmann Machines', 2, None, '___sec9'),
('Python and Scikit Learn, a short guide', 2, None, '___sec10'),
('Teach yourself C++', 2, None, '___sec11'),
('Projects Fall 2017', 2, None, '___sec12'),
('Project', 3, None, '___sec13'),
('Course content', 3, None, '___sec14'),
('Learning outcomes', 2, None, '___sec15'),
('Prerequisites', 2, None, '___sec16'),
('The course has two central parts', 2, None, '___sec17'),
('Statistical analysis and optimization of data',
3,
None,
'___sec17'),
('Machine learning', 3, None, '___sec18'),
'___sec18'),
('Machine learning', 3, None, '___sec19'),
('"Possible '
'textbooks":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks"',
2,
None,
'___sec19')]}
'___sec20')]}
end of tocinfo -->
<body>
@@ -487,9 +488,45 @@ formulas in HTML or ipython notebook files.
</ul>
<h2 id="___sec9">Unsupervised Learning, Boltzmann Machines </h2>
<ul>
<li> LaTeX PDF:</li>
<ul>
<li> For printing:</li>
<ul>
<li> <a href="https://compphysics.github.io/MachineLearning/doc/pub/BM/pdf/BM-minted.pdf" target="_self">Standard one-page format</a></li>
</ul>
<li> For screen viewing:</li>
<ul>
<li> <a href="https://compphysics.github.io/MachineLearning/doc/pub/BM/pdf/BM-beamer.pdf" target="_self">standard Beamer format</a></li>
</ul>
</ul>
<li> HTML:</li>
<ul>
<li> <a href="https://compphysics.github.io/MachineLearning/doc/pub/BM/html/BM.html" target="_self">Plain html</a></li>
<li> <a href="https://compphysics.github.io/MachineLearning/doc/pub/BM/html/BM-reveal.html" target="_self">reveal.js beige slide style</a></li>
<li> <a href="https://compphysics.github.io/MachineLearning/doc/pub/BM/html/BM-bs.html" target="_self">Bootstrap slide style, easy for reading on mobile devices</a></li>
</ul>
<li> iPython notebook:</li>
<ul>
<li> <a href="https://compphysics.github.io/MachineLearning/doc/pub/BM/ipynb/BM.ipynb" target="_self">ipynb file</a></li>
</ul>
</ul>
<!-- !split -->
<h2 id="___sec9">Python and Scikit Learn, a short guide </h2>
<h2 id="___sec10">Python and Scikit Learn, a short guide </h2>
<ul>
<li> HTML format only:</li>
@@ -502,7 +539,7 @@ formulas in HTML or ipython notebook files.
<!-- !split -->
<h2 id="___sec10">Teach yourself C++ </h2>
<h2 id="___sec11">Teach yourself C++ </h2>
<ul>
<li> HTML format only:</li>
@@ -515,9 +552,9 @@ formulas in HTML or ipython notebook files.
<!-- !split -->
<h2 id="___sec11">Projects Fall 2017 </h2>
<h2 id="___sec12">Projects Fall 2017 </h2>
<h3 id="___sec12">Project </h3>
<h3 id="___sec13">Project </h3>
<ul>
<li> LaTeX and PDF:</li>
@@ -536,7 +573,7 @@ formulas in HTML or ipython notebook files.
</ul>
<h3 id="___sec13">Course content </h3>
<h3 id="___sec14">Course content </h3>
<p>
Probability theory and statistical methods play a central role in science. Nowadays we are
@@ -555,7 +592,7 @@ tools of probability theory, the aim of this course is to expose you to central
This course covers thus topics like Monte Carlo methods and Markov chains, Bayesian statistics, error estimates, various linear methods, optimization of data and error analysis and central algorithms in machine learning.
The course has several numerical projects and numerical exercises that are meant to illustrate the theory.
<h2 id="___sec14">Learning outcomes </h2>
<h2 id="___sec15">Learning outcomes </h2>
<p>
The course introduces a variety of central algorithms and methods
@@ -572,19 +609,19 @@ essential for studies of data analysis and machine learning. The course is proje
<li> Work on numerical projects to illustrate the theory. The projects play a central role and students are expected to know modern programming languages like Python or C++.</li>
</ul>
<h2 id="___sec15">Prerequisites </h2>
<h2 id="___sec16">Prerequisites </h2>
<p>
Basic knowledge in programming and numerics. Required courses are the equivalents to the University of Oslo mathematics courses MAT1100, MAT1110, MAT1120 and at least one of the corresponding computing and programming courses INF1000/INF1110 or MAT-INF1100/MAT-INF1100L/BIOS1100/KJM-INF1xxx.
<h2 id="___sec16">The course has two central parts </h2>
<h2 id="___sec17">The course has two central parts </h2>
<ol>
<li> Statistical analysis and optimization of data</li>
<li> Machine learning</li>
</ol>
<h3 id="___sec17">Statistical analysis and optimization of data </h3>
<h3 id="___sec18">Statistical analysis and optimization of data </h3>
<p>
The following topics will be covered
@@ -601,7 +638,7 @@ The following topics will be covered
<li> Practical optimization using Singular-value decomposition and least squares for parameterizing data.</li>
</ul>
<h3 id="___sec18">Machine learning </h3>
<h3 id="___sec19">Machine learning </h3>
<p>
The following topics will be covered
@@ -617,7 +654,7 @@ The following topics will be covered
All the above topics will be supported by examples, hands-on exercises and project work.
<h2 id="___sec19"><a href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks" target="_self">Possible textbooks</a> </h2>
<h2 id="___sec20"><a href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks" target="_self">Possible textbooks</a> </h2>
<p>
<b>General learning book on statistical analysis</b>: