`Gibbs`

Inherits From: `MonteCarlo`

- Class
`ed.Gibbs`

- Class
`ed.inferences.Gibbs`

Defined in `edward/inferences/gibbs.py`

.

Gibbs sampling (Geman and Geman, 1984).

```
x_data = np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 1])
p = Beta(1.0, 1.0)
x = Bernoulli(probs=p, sample_shape=10)
qp = Empirical(tf.Variable(tf.zeros(500)))
inference = ed.Gibbs({p: qp}, data={x: x_data})
```

**init**

```
__init__(
latent_vars,
proposal_vars=None,
data=None
)
```

Create an inference algorithm.

: dict of RandomVariable to RandomVariable, optional. Collection of random variables to perform inference on; each is binded to its complete conditionals which Gibbs cycles draws on. If not specified, default is to use`proposal_vars`

`ed.complete_conditional`

.

`build_update`

`build_update()`

The updates assume each Empirical random variable is directly parameterized by `tf.Variable`

s.

`finalize`

`finalize()`

Function to call after convergence.

`initialize`

```
initialize(
scan_order='random',
*args,
**kwargs
)
```

Initialize inference algorithm. It initializes hyperparameters and builds ops for the algorithm's computation graph.

: list or str, optional. The scan order for each Gibbs update. If list, it is the deterministic order of latent variables. An element in the list can be a`scan_order`

`RandomVariable`

or itself a list of`RandomVariable`

s (this defines a blocked Gibbs sampler). If 'random', will use a random order at each update.

`print_progress`

`print_progress(info_dict)`

Print progress to output.

`run`

```
run(
variables=None,
use_coordinator=True,
*args,
**kwargs
)
```

A simple wrapper to run inference.

- Initialize algorithm via
`initialize`

. - (Optional) Build a TensorFlow summary writer for TensorBoard.
- (Optional) Initialize TensorFlow variables.
- (Optional) Start queue runners.
- Run
`update`

for`self.n_iter`

iterations. - While running,
`print_progress`

. - Finalize algorithm via
`finalize`

. - (Optional) Stop queue runners.

To customize the way inference is run, run these steps individually.

: list, optional. 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.`variables`

: bool, optional. 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`use_coordinator`

`initialize`

.

`update`

`update(feed_dict=None)`

Run one iteration of sampling.

: dict, optional. Feed dictionary for a TensorFlow session run. It is used to feed placeholders that are not fed during initialization.`feed_dict`

dict. Dictionary of algorithm-specific information. In this case, the acceptance rate of samples since (and including) this iteration.