Skip to content

Commit 5e83fa7

Browse files
ferrinetwiecki
authored andcommitted
Better docs for mini-batch and total_size (#3221)
1 parent 4952b8e commit 5e83fa7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

docs/source/notebooks/variational_api_quickstart.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,9 @@
14511451
"\n",
14521452
"Now let's use minibatches. At every iteration, we will draw 500 random values:\n",
14531453
"\n",
1454-
"> Remember to set `total_size` in observed"
1454+
"> Remember to set `total_size` in observed\n",
1455+
"\n",
1456+
"**total_size** is an important parameter that allows pymc3 to infer the right way of rescaling densities. If it is not set, you are likely to get completely wrong results. For more information please refer to the comprehensive documentation of `pm.Minibatch`."
14551457
]
14561458
},
14571459
{
@@ -1684,7 +1686,7 @@
16841686
"name": "python",
16851687
"nbconvert_exporter": "python",
16861688
"pygments_lexer": "ipython3",
1687-
"version": "3.6.0b4"
1689+
"version": "3.6.3"
16881690
}
16891691
},
16901692
"nbformat": 4,

pymc3/data.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ class Minibatch(tt.TensorVariable):
124124
minibatch : minibatch tensor
125125
Used for training
126126
127+
Notes
128+
-----
129+
Below is a common use case of Minibatch within the variational inference.
130+
Importantly, we need to make PyMC3 "aware" of minibatch being used in inference.
131+
Otherwise, we will get the wrong :math:`logp` for the model.
132+
To do so, we need to pass the `total_size` parameter to the observed node, which correctly scales
133+
the density of the model logp that is affected by Minibatch. See more in examples below.
134+
127135
Examples
128136
--------
129137
Consider we have data

0 commit comments

Comments
 (0)