Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinvtran committed Apr 30, 2018
1 parent cd950bd commit 698da3b
Show file tree
Hide file tree
Showing 71 changed files with 2,602 additions and 838 deletions.
7 changes: 7 additions & 0 deletions api/ed.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ <h2 id="classes">Classes</h2>
<p><a href="./ed/ReparameterizationEntropyKLqp"><code>class ReparameterizationEntropyKLqp</code></a>: Variational inference with the KL divergence</p>
<p><a href="./ed/ReparameterizationKLKLqp"><code>class ReparameterizationKLKLqp</code></a>: Variational inference with the KL divergence</p>
<p><a href="./ed/ReparameterizationKLqp"><code>class ReparameterizationKLqp</code></a>: Variational inference with the KL divergence</p>
<p><a href="./ed/ReplicaExchangeMC"><code>class ReplicaExchangeMC</code></a>: Replica Exchange MCMC <span class="citation" data-cites="swendsen1986replica hukushima1996exchange">(Hukushima &amp; Nemoto, 1996; Swendsen &amp; Wang, 1986)</span>.</p>
<p><a href="./ed/SGHMC"><code>class SGHMC</code></a>: Stochastic gradient Hamiltonian Monte Carlo <span class="citation" data-cites="chen2014stochastic">(Chen, Fox, &amp; Guestrin, 2014)</span>.</p>
<p><a href="./ed/SGLD"><code>class SGLD</code></a>: Stochastic gradient Langevin dynamics <span class="citation" data-cites="welling2011bayesian">(Welling &amp; Teh, 2011)</span>.</p>
<p><a href="./ed/ScoreEntropyKLqp"><code>class ScoreEntropyKLqp</code></a>: Variational inference with the KL divergence</p>
Expand Down Expand Up @@ -189,12 +190,18 @@ <h2 id="other-members">Other Members</h2>
<div id="ref-hinton1995wake">
<p>Hinton, G. E., Dayan, P., Frey, B. J., &amp; Neal, R. M. (1995). The &quot;wake-sleep&quot; algorithm for unsupervised neural networks. <em>Science</em>.</p>
</div>
<div id="ref-hukushima1996exchange">
<p>Hukushima, K., &amp; Nemoto, K. (1996). Exchange monte carlo method and application to spin glass simulations. <em>Journal of the Physical Society of Japan</em>, <em>65</em>(6), 1604–1608.</p>
</div>
<div id="ref-laplace1986memoir">
<p>Laplace, P. S. (1986). Memoir on the probability of the causes of events. <em>Statistical Science</em>, <em>1</em>(3), 364–378.</p>
</div>
<div id="ref-metropolis1953equation">
<p>Metropolis, N., Rosenbluth, A. W., Rosenbluth, M. N., Teller, A. H., &amp; Teller, E. (1953). Equation of state calculations by fast computing machines. <em>The Journal of Chemical Physics</em>, <em>21</em>(6), 1087–1092.</p>
</div>
<div id="ref-swendsen1986replica">
<p>Swendsen, R. H., &amp; Wang, J.-S. (1986). Replica monte carlo simulation of spin-glasses. <em>Physical Review Letters</em>, <em>57</em>(21), 2607.</p>
</div>
<div id="ref-welling2011bayesian">
<p>Welling, M., &amp; Teh, Y. W. (2011). Bayesian learning via stochastic gradient Langevin dynamics. In <em>International conference on machine learning</em>.</p>
</div>
Expand Down
23 changes: 13 additions & 10 deletions api/ed/RandomVariable.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ <h3 id="__ge__">
<p><em>NOTE</em>: <code>GreaterEqual</code> supports broadcasting. More about broadcasting <a href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html">here</a></p>
<h4 id="args-6">Args:</h4>
<ul>
<li><b><code>x</code></b>: A <code>Tensor</code>. Must be one of the following types: <code>float32</code>, <code>float64</code>, <code>int32</code>, <code>int64</code>, <code>uint8</code>, <code>int16</code>, <code>int8</code>, <code>uint16</code>, <code>half</code>, <code>uint32</code>, <code>uint64</code>, <code>bfloat16</code>.</li>
<li><b><code>x</code></b>: A <code>Tensor</code>. Must be one of the following types: <code>float32</code>, <code>float64</code>, <code>int32</code>, <code>uint8</code>, <code>int16</code>, <code>int8</code>, <code>int64</code>, <code>bfloat16</code>, <code>uint16</code>, <code>half</code>, <code>uint32</code>, <code>uint64</code>.</li>
<li><b><code>y</code></b>: A <code>Tensor</code>. Must have the same type as <code>x</code>.</li>
<li><b><code>name</code></b>: A name for the operation (optional).</li>
</ul>
Expand All @@ -340,15 +340,18 @@ <h3 id="__getitem__">
*args
)</code></pre>
<p>Overload for Tensor.__getitem__.</p>
<p>This operation extracts the specified region from the tensor. The notation is similar to NumPy with the restriction that currently only support basic indexing. That means that using a tensor as input is not currently allowed</p>
<p>This operation extracts the specified region from the tensor. The notation is similar to NumPy with the restriction that currently only support basic indexing. That means that using a non-scalar tensor as input is not currently allowed.</p>
<p>Some useful examples:</p>
<pre class="python"><code># strip leading and trailing 2 elements
foo = tf.constant([1,2,3,4,5,6])
print(foo[2:-2].eval()) # [3,4]
print(foo[2:-2].eval()) # =&gt; [3,4]

# skip every row and reverse every column
foo = tf.constant([[1,2,3], [4,5,6], [7,8,9]])
print(foo[::2,::-1].eval()) # [[3,2,1], [9,8,7]]
print(foo[::2,::-1].eval()) # =&gt; [[3,2,1], [9,8,7]]

# Use scalar tensors as indices on both dimensions
print(foo[tf.constant(0), tf.constant(2)].eval()) # =&gt; 3

# Insert another dimension
foo = tf.constant([[1,2,3], [4,5,6], [7,8,9]])
Expand All @@ -359,9 +362,9 @@ <h3 id="__getitem__">

# Ellipses (3 equivalent operations)
foo = tf.constant([[1,2,3], [4,5,6], [7,8,9]])
print(foo[tf.newaxis, :, :].eval()) # [[[1,2,3], [4,5,6], [7,8,9]]]
print(foo[tf.newaxis, ...].eval()) # [[[1,2,3], [4,5,6], [7,8,9]]]
print(foo[tf.newaxis].eval()) # [[[1,2,3], [4,5,6], [7,8,9]]]</code></pre>
print(foo[tf.newaxis, :, :].eval()) # =&gt; [[[1,2,3], [4,5,6], [7,8,9]]]
print(foo[tf.newaxis, ...].eval()) # =&gt; [[[1,2,3], [4,5,6], [7,8,9]]]
print(foo[tf.newaxis].eval()) # =&gt; [[[1,2,3], [4,5,6], [7,8,9]]]</code></pre>
<p>Notes: - <code>tf.newaxis</code> is <code>None</code> as in NumPy. - An implicit ellipsis is placed at the end of the <code>slice_spec</code> - NumPy advanced indexing is currently not supported.</p>
<h4 id="args-7">Args:</h4>
<ul>
Expand All @@ -387,7 +390,7 @@ <h3 id="__gt__">
<p><em>NOTE</em>: <code>Greater</code> supports broadcasting. More about broadcasting <a href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html">here</a></p>
<h4 id="args-8">Args:</h4>
<ul>
<li><b><code>x</code></b>: A <code>Tensor</code>. Must be one of the following types: <code>float32</code>, <code>float64</code>, <code>int32</code>, <code>int64</code>, <code>uint8</code>, <code>int16</code>, <code>int8</code>, <code>uint16</code>, <code>half</code>, <code>uint32</code>, <code>uint64</code>, <code>bfloat16</code>.</li>
<li><b><code>x</code></b>: A <code>Tensor</code>. Must be one of the following types: <code>float32</code>, <code>float64</code>, <code>int32</code>, <code>uint8</code>, <code>int16</code>, <code>int8</code>, <code>int64</code>, <code>bfloat16</code>, <code>uint16</code>, <code>half</code>, <code>uint32</code>, <code>uint64</code>.</li>
<li><b><code>y</code></b>: A <code>Tensor</code>. Must have the same type as <code>x</code>.</li>
<li><b><code>name</code></b>: A name for the operation (optional).</li>
</ul>
Expand Down Expand Up @@ -423,7 +426,7 @@ <h3 id="__le__">
<p><em>NOTE</em>: <code>LessEqual</code> supports broadcasting. More about broadcasting <a href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html">here</a></p>
<h4 id="args-10">Args:</h4>
<ul>
<li><b><code>x</code></b>: A <code>Tensor</code>. Must be one of the following types: <code>float32</code>, <code>float64</code>, <code>int32</code>, <code>int64</code>, <code>uint8</code>, <code>int16</code>, <code>int8</code>, <code>uint16</code>, <code>half</code>, <code>uint32</code>, <code>uint64</code>, <code>bfloat16</code>.</li>
<li><b><code>x</code></b>: A <code>Tensor</code>. Must be one of the following types: <code>float32</code>, <code>float64</code>, <code>int32</code>, <code>uint8</code>, <code>int16</code>, <code>int8</code>, <code>int64</code>, <code>bfloat16</code>, <code>uint16</code>, <code>half</code>, <code>uint32</code>, <code>uint64</code>.</li>
<li><b><code>y</code></b>: A <code>Tensor</code>. Must have the same type as <code>x</code>.</li>
<li><b><code>name</code></b>: A name for the operation (optional).</li>
</ul>
Expand All @@ -440,7 +443,7 @@ <h3 id="__lt__">
<p><em>NOTE</em>: <code>Less</code> supports broadcasting. More about broadcasting <a href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html">here</a></p>
<h4 id="args-11">Args:</h4>
<ul>
<li><b><code>x</code></b>: A <code>Tensor</code>. Must be one of the following types: <code>float32</code>, <code>float64</code>, <code>int32</code>, <code>int64</code>, <code>uint8</code>, <code>int16</code>, <code>int8</code>, <code>uint16</code>, <code>half</code>, <code>uint32</code>, <code>uint64</code>, <code>bfloat16</code>.</li>
<li><b><code>x</code></b>: A <code>Tensor</code>. Must be one of the following types: <code>float32</code>, <code>float64</code>, <code>int32</code>, <code>uint8</code>, <code>int16</code>, <code>int8</code>, <code>int64</code>, <code>bfloat16</code>, <code>uint16</code>, <code>half</code>, <code>uint32</code>, <code>uint64</code>.</li>
<li><b><code>y</code></b>: A <code>Tensor</code>. Must have the same type as <code>x</code>.</li>
<li><b><code>name</code></b>: A name for the operation (optional).</li>
</ul>
Expand Down
234 changes: 234 additions & 0 deletions api/ed/ReplicaExchangeMC.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title>Edward – ed.ReplicaExchangeMC</title>
<!-- Mobile Specific Metas -->
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- FONT -->
<link href="https://fonts.googleapis.com/css?family=Lora:400,400i,700" rel="stylesheet">

<!-- CSS -->
<link rel="stylesheet" href="/css/normalize.css">
<link rel="stylesheet" href="/css/skeleton.css">
<!-- Dynamically resize logo for mobile -->
<style type="text/css">
.logo-width {
width: 100%;
box-sizing: border-box;
margin-bottom: 15%;
}
/* Roughly the point when website is single column */
@media (max-width: 850px) {
.logo-width {
width: 50%;
box-sizing: border-box;
margin-bottom: 5%;
}
}
/* Downgrade API's header styles without explicitly modifying their type. */
div.nine.columns h1 { text-align: left; }
div.nine.columns h1 { font-size: 3.0rem; line-height: 1.25; letter-spacing: -.1rem; }
div.nine.columns h2 { font-size: 2.4rem; line-height: 1.3; letter-spacing: -.1rem; }
div.nine.columns h3 { font-size: 2.4rem; line-height: 1.35; letter-spacing: -.08rem; }
div.nine.columns h4 { font-size: 1.8rem; line-height: 1.5; letter-spacing: -.05rem; }
div.nine.columns h5 { font-size: 1.5rem; line-height: 1.6; letter-spacing: 0; }
@media (min-width: 550px) {
div.nine.columns h1 { font-size: 3.6rem; }
div.nine.columns h2 { font-size: 3.0rem; }
div.nine.columns h3 { font-size: 3.0rem; }
div.nine.columns h4 { font-size: 2.5rem; }
div.nine.columns h5 { font-size: 1.5rem; }
}
</style>

<!-- KaTeX -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/contrib/auto-render.min.js"></script>

<!-- highlight.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/github.min.css">

<!-- Favicon -->
<link rel="apple-touch-icon" sizes="57x57" href="/icons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/icons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/icons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/icons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/icons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/icons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/icons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/icons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/icons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/icons/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/icons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/icons/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/icons/manifest.json">
<link rel="mask-icon" href="/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="/icons/mstile-144x144.png">
<meta name="msapplication-config" content="/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<div class="container">
<div class="row" style="margin-top: 5%">
<div class="three columns">
<h1><a href="/">Edward</a></h1>
<a href="/">
<center>
<img src="/images/edward.png" class="logo-width" alt="Edward" />
</center>
</a>
<a class="button u-full-width" href="/api/">API</a>
<hr style="margin-top: 1rem; margin-bottom: 1.5rem;"/>
<a class="button u-full-width" href="/api/reference">Reference</a>
<a class="button u-full-width" href="/api/ed/criticisms">ed.criticisms</a>
<a class="button u-full-width" href="/api/ed/inferences">ed.inferences</a>
<a class="button u-full-width" href="/api/ed/models">ed.models</a>
<a class="button u-full-width" href="/api/ed/util">ed.util</a>
<a class="button u-full-width" href="/api/observations">observations</a>

<div class="row" style="padding-bottom: 5%"> </div>
<a class="button2 u-pull-right" style="padding-right:10%"
href="https://github.com/blei-lab/edward">
<span style="vertical-align:middle;">Github</span>&nbsp;
<img src="/images/github-mark.svg" style="vertical-align:middle;"
alt="Edward on Github" />
</a>
<div class="row" style="padding-bottom: 5%"> </div>
</div>
<div class="nine columns">

<div itemscope itemtype="http://developers.google.com/ReferenceObject">
<meta itemprop="name" content="ed.ReplicaExchangeMC" />
<meta itemprop="property" content="__init__"/>
<meta itemprop="property" content="build_update"/>
<meta itemprop="property" content="finalize"/>
<meta itemprop="property" content="initialize"/>
<meta itemprop="property" content="print_progress"/>
<meta itemprop="property" content="run"/>
<meta itemprop="property" content="update"/>
</div>
<h1 id="ed.replicaexchangemc">ed.ReplicaExchangeMC</h1>
<h2 id="class-replicaexchangemc">Class <code>ReplicaExchangeMC</code></h2>
<p>Inherits From: <a href="../ed/MonteCarlo"><code>MonteCarlo</code></a></p>
<h3 id="aliases">Aliases:</h3>
<ul>
<li>Class <code>ed.ReplicaExchangeMC</code></li>
<li>Class <code>ed.inferences.ReplicaExchangeMC</code></li>
</ul>
<p>Defined in <a href="https://github.com/blei-lab/edward/tree/master/edward/inferences/replica_exchange_mc.py"><code>edward/inferences/replica_exchange_mc.py</code></a>.</p>
<p>Replica Exchange MCMC <span class="citation" data-cites="swendsen1986replica hukushima1996exchange">(Hukushima &amp; Nemoto, 1996; Swendsen &amp; Wang, 1986)</span>.</p>
<h4 id="examples">Examples</h4>
<pre class="python"><code>cat = Categorical(probs=[0.5,0.5])
x = Mixture(cat=cat, components=[
MultivariateNormalDiag([0.0,0.0], [1.0,1.0]),
MultivariateNormalDiag([10.0,10.0], [1.0,1.0])])
proposal_x = MultivariateNormalDiag(x, [1.0,1.0])
qx = Empirical(tf.Variable(tf.zeros([10000, 2])))
inference = ed.ReplicaExchangeMC(latent_vars={x: qx},
proposal_vars={x: proposal_x})</code></pre>
<h2 id="methods">Methods</h2>
<h3 id="__init__">
<code><strong>init</strong></code>
</h3>
<pre class="python"><code>__init__(
latent_vars,
proposal_vars,
data=None,
inverse_temperatures=np.logspace(0, -2, 5),
exchange_freq=0.1
)</code></pre>
<p>Create an inference algorithm.</p>
<h4 id="args">Args:</h4>
<ul>
<li><b><code>proposal_vars</code></b>: dict of RandomVariable to RandomVariable. Collection of random variables to perform inference on; each is binded to a proposal distribution <span class="math inline">\(g(z&#39; \mid z)\)</span>.</li>
<li><b><code>inverse_temperatures</code></b>: list of inverse temperature.</li>
<li><b><code>exchange_freq</code></b>: frequency of exchanging replica.</li>
</ul>
<h3 id="build_update">
<code>build_update</code>
</h3>
<pre class="python"><code>build_update()</code></pre>
<p>Perform sampling and exchange.</p>
<h3 id="finalize">
<code>finalize</code>
</h3>
<pre class="python"><code>finalize()</code></pre>
<p>Function to call after convergence.</p>
<h3 id="initialize">
<code>initialize</code>
</h3>
<pre class="python"><code>initialize(
*args,
**kwargs
)</code></pre>
<h3 id="print_progress">
<code>print_progress</code>
</h3>
<pre class="python"><code>print_progress(info_dict)</code></pre>
<p>Print progress to output.</p>
<h3 id="run">
<code>run</code>
</h3>
<pre class="python"><code>run(
variables=None,
use_coordinator=True,
*args,
**kwargs
)</code></pre>
<p>A simple wrapper to run inference.</p>
<ol type="1">
<li>Initialize algorithm via <code>initialize</code>.</li>
<li>(Optional) Build a TensorFlow summary writer for TensorBoard.</li>
<li>(Optional) Initialize TensorFlow variables.</li>
<li>(Optional) Start queue runners.</li>
<li>Run <code>update</code> for <code>self.n_iter</code> iterations.</li>
<li>While running, <code>print_progress</code>.</li>
<li>Finalize algorithm via <code>finalize</code>.</li>
<li>(Optional) Stop queue runners.</li>
</ol>
<p>To customize the way inference is run, run these steps individually.</p>
<h4 id="args-1">Args:</h4>
<ul>
<li><b><code>variables</code></b>: list. A list of TensorFlow variables to initialize during inference. Default is to initialize all variables (this includes reinitializing variables that were already initialized). To avoid initializing any variables, pass in an empty list.</li>
<li><b><code>use_coordinator</code></b>: bool. Whether to start and stop queue runners during inference using a TensorFlow coordinator. For example, queue runners are necessary for batch training with file readers. *args, **kwargs: Passed into <code>initialize</code>.</li>
</ul>
<h3 id="update">
<code>update</code>
</h3>
<pre class="python"><code>update(feed_dict=None)</code></pre>
<p>Run one iteration of sampling.</p>
<h4 id="args-2">Args:</h4>
<ul>
<li><b><code>feed_dict</code></b>: dict. Feed dictionary for a TensorFlow session run. It is used to feed placeholders that are not fed during initialization.</li>
</ul>
<h4 id="returns">Returns:</h4>
<p>dict. Dictionary of algorithm-specific information. In this case, the acceptance rate of samples since (and including) this iteration.</p>
<h4 id="notes">Notes</h4>
<p>We run the increment of <code>t</code> separately from other ops. Whether the others op run with the <code>t</code> before incrementing or after incrementing depends on which is run faster in the TensorFlow graph. Running it separately forces a consistent behavior.</p>
<div id="refs" class="references">
<div id="ref-hukushima1996exchange">
<p>Hukushima, K., &amp; Nemoto, K. (1996). Exchange monte carlo method and application to spin glass simulations. <em>Journal of the Physical Society of Japan</em>, <em>65</em>(6), 1604–1608.</p>
</div>
<div id="ref-swendsen1986replica">
<p>Swendsen, R. H., &amp; Wang, J.-S. (1986). Replica monte carlo simulation of spin-glasses. <em>Physical Review Letters</em>, <em>57</em>(21), 2607.</p>
</div>
</div>
</div>
</div>
<div class="row" style="padding-bottom: 25%"> </div>
</div>
<script>
hljs.initHighlightingOnLoad();
renderMathInElement(document.body);
</script>
</body>
</html>
Loading

0 comments on commit 698da3b

Please sign in to comment.