Skip to content

Commit 48c081f

Browse files
ferrinetaku-y
authored andcommitted
fix docstrings, thanks @fonnesbeck
1 parent 8388272 commit 48c081f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pymc3/data.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ class Minibatch(tt.TensorVariable):
124124
125125
if we want 1d slice of size 10 we do
126126
>>> x = Minibatch(data, batch_size=10)
127-
128-
Note, that your data is casted to `floatX` if it is not integer type
127+
128+
Note, that your data is cast to `floatX` if it is not integer type
129129
But you still can add dtype kwarg for :class:`Minibatch`
130130
131131
in case we want 10 sampled rows and columns
@@ -158,15 +158,15 @@ class Minibatch(tt.TensorVariable):
158158
it directly affects `x.shared`.
159159
the same thing would be but less convenient
160160
>>> x.shared.set_value(pm.floatX(np.random.laplace(size=(100, 100))))
161-
162-
programmatic way to change storage is as following
161+
162+
programmatic way to change storage is as follows
163163
I import `partial` for simplicity
164164
>>> from functools import partial
165165
>>> datagen = partial(np.random.laplace, size=(100, 100))
166166
>>> x = Minibatch(datagen(), batch_size=100, update_shared_f=datagen)
167167
>>> x.update_shared()
168168
169-
To be more precise of how we get minibatch, here is a demo
169+
To be more concrete about how we get minibatch, here is a demo
170170
1) create shared variable
171171
>>> shared = theano.shared(data)
172172
@@ -179,11 +179,16 @@ class Minibatch(tt.TensorVariable):
179179
That's done. So if you'll need some replacements in the graph
180180
>>> testdata = pm.floatX(np.random.laplace(size=(1000, 10)))
181181
182-
you are free to use a kind of this one as `x` is regular Theano Tensor
182+
To change minibatch with static data you can create a dict with replacements
183183
>>> replacements = {x: testdata}
184184
>>> node = x ** 2 # arbitrary expressions
185185
>>> rnode = theano.clone(node, replacements)
186186
>>> assert (testdata ** 2 == rnode.eval()).all()
187+
188+
To replace minibatch with it's shared variable
189+
instead of static `np.array` you should do
190+
>>> replacements = {x.minibatch: x.shared}
191+
>>> rnode = theano.clone(node, replacements)
187192
188193
For more complex slices some more code is needed that can seem not so clear
189194
They are
@@ -205,7 +210,6 @@ class Minibatch(tt.TensorVariable):
205210
3) mixing that all, total_size = (10, None, 30, Ellipsis, 50)
206211
>>> x = Minibatch(moredata, [2, None, 20, Ellipsis, 10])
207212
>>> assert x.eval().shape == (2, 20, 20, 40, 10)
208-
209213
"""
210214
@theano.configparser.change_flags(compute_test_value='raise')
211215
def __init__(self, data, batch_size=128, in_memory_size=None,

0 commit comments

Comments
 (0)