Skip to content

Commit 9cdc4ee

Browse files
Fixed few code lines in this API example
Updated `axis` to `axes` as per tf.nn.moments() actual syntax and added full alias name (tfp.mcmc.) to effective_sample_size() to execute the example successfully. I have replicated and fixed the code error of this API example in this [gist](https://colab.sandbox.google.com/gist/RenuPatelGoogle/9a528802d6e52e46ad9713c6391bbc5c/tfp-mcmc-effective_sample_size.ipynb#scrollTo=pW_kQ2Px3VLs) for your reference.
1 parent f8107c1 commit 9cdc4ee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tensorflow_probability/python/mcmc/diagnostic.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,14 @@ def effective_sample_size(states,
160160
target_log_prob_fn=target.log_prob,
161161
step_size=0.05,
162162
num_leapfrog_steps=20))
163-
states.shape
163+
print(states.shape)
164164
==> (1000, 2)
165165
166166
ess = effective_sample_size(states, filter_beyond_positive_pairs=True)
167-
==> Shape (2,) Tensor
167+
print(ess.shape)
168+
==> (2,)
168169
169-
mean, variance = tf.nn.moments(states, axis=0)
170+
mean, variance = tf.nn.moments(states, axes=0)
170171
standard_error = tf.sqrt(variance / ess)
171172
```
172173

0 commit comments

Comments
 (0)