Google I/O is a wrap! Catch up on TensorFlow sessions

# tfp.experimental.mcmc.SequentialMonteCarlo

Sequential Monte Carlo transition kernel.

Inherits From: `TransitionKernel`

Sequential Monte Carlo maintains a population of weighted particles representing samples from a sequence of target distributions. It is not a calibrated MCMC kernel: the transitions step through a sequence of target distributions, rather than trying to maintain a stationary distribution.

`propose_and_update_log_weights_fn` Python `callable` with signature ```new_weighted_particles = propose_and_update_log_weights_fn(step, weighted_particles, seed=None)```. Its input is a `tfp.experimental.mcmc.WeightedParticles` structure representing weighted samples (with normalized weights) from the `step`th target distribution, and it returns another such structure representing unnormalized weighted samples from the next (`step + 1`th) target distribution. This will typically include particles sampled from a proposal distribution `q(x[step + 1] | x[step])`, and weights that account for some or all of: the proposal density, a transition density ```p(x[step + 1] | x[step]), observation weights```p(y[step + 1] | x[step + 1])```, and/or a backwards or 'L'-kernel```L(x[step] | x[step + 1])```. The (log) normalization constant of the weights is interpreted as the incremental (log) marginal likelihood. </td> </tr><tr> <td>```resample_fn```</td> <td> Resampling scheme specified as a```callable`with signature`indices = resample_fn(log_probs, event_size, sample_shape, seed)```, where```log_probs`is a`Tensor`of the same shape as`state.log_weights```containing a normalized log-probability for every current particle,```event_size```is the number of new particle indices to generate,```sample_shape```is the number of independent index sets to return, and the return value```indices`is an`int`Tensor of shape`concat([sample_shape, [event_size, B1, ..., BN])```. Typically one of <a href="../../../tfp/experimental/mcmc/resample_deterministic_minimum_error"><code>tfp.experimental.mcmc.resample_deterministic_minimum_error</code></a>, <a href="../../../tfp/experimental/mcmc/resample_independent"><code>tfp.experimental.mcmc.resample_independent</code></a>, <a href="../../../tfp/experimental/mcmc/resample_stratified"><code>tfp.experimental.mcmc.resample_stratified</code></a>, or <a href="../../../tfp/experimental/mcmc/resample_systematic"><code>tfp.experimental.mcmc.resample_systematic</code></a>. Default value: <a href="../../../tfp/experimental/mcmc/resample_systematic"><code>tfp.experimental.mcmc.resample_systematic</code></a>. </td> </tr><tr> <td>```resample_criterion_fn```</td> <td> optional Python```callable`with signature`do_resample = resample_criterion_fn(weighted_particles)```, passed an instance of <a href="../../../tfp/experimental/mcmc/WeightedParticles"><code>tfp.experimental.mcmc.WeightedParticles</code></a>. The return value```do_resample```determines whether particles are resampled at the current step. The default behavior is to resample particles when the effective sample size falls below half of the total number of particles. Default value: <a href="../../../tfp/experimental/mcmc/ess_below_threshold"><code>tfp.experimental.mcmc.ess_below_threshold</code></a>. </td> </tr><tr> <td>```unbiased_gradients```</td> <td> If```True```, use the stop-gradient resampling trick of Scibior, Masrani, and Wood [{scibor_ref_idx}] to correct for gradient bias introduced by the discrete resampling step. This will generally increase the variance of stochastic gradients. Default value:```True```. </td> </tr><tr> <td>```name```</td> <td> Python```str` name for ops created by this kernel.

`experimental_shard_axis_names` The shard axis names for members of the state.
`is_calibrated` Returns `True` if Markov chain converges to specified distribution.

`TransitionKernel`s which are "uncalibrated" are often calibrated by composing them with the `tfp.mcmc.MetropolisHastings` `TransitionKernel`.

`name`

`propose_and_update_log_weights_fn`

`resample_criterion_fn`

`resample_fn`

`unbiased_gradients`

## Methods

### `bootstrap_results`

View source

Returns an object with the same type as returned by `one_step(...)[1]`.

Args
`init_state` `Tensor` or Python `list` of `Tensor`s representing the initial state(s) of the Markov chain(s).

Returns
`kernel_results` A (possibly nested) `tuple`, `namedtuple` or `list` of `Tensor`s representing internal calculations made within this function.

### `copy`

View source

Non-destructively creates a deep copy of the kernel.

Args
`**override_parameter_kwargs` Python String/value `dictionary` of initialization arguments to override with new values.

Returns
`new_kernel` `TransitionKernel` object of same type as `self`, initialized with the union of self.parameters and override_parameter_kwargs, with any shared keys overridden by the value of override_parameter_kwargs, i.e., `dict(self.parameters, **override_parameters_kwargs)`.

### `experimental_with_shard_axes`

View source

Returns a copy of the kernel with the provided shard axis names.

Args
`shard_axis_names` a structure of strings indicating the shard axis names for each component of this kernel's state.

Returns
A copy of the current kernel with the shard axis information.

### `one_step`

View source

Takes one Sequential Monte Carlo inference step.

Args
`state` instance of `tfp.experimental.mcmc.WeightedParticles` representing the current particles with (log) weights. The `log_weights` must be a float `Tensor` of shape `[num_particles, b1, ..., bN]`. The `particles` may be any structure of `Tensor`s, each of which must have shape `concat([log_weights.shape, event_shape])` for some `event_shape`, which may vary across components.
`kernel_results` instance of `tfp.experimental.mcmc.SequentialMonteCarloResults` representing results from a previous step.
`seed` PRNG seed; see `tfp.random.sanitize_seed` for details.

Returns
`state` instance of `tfp.experimental.mcmc.WeightedParticles` representing new particles with (log) weights.
`kernel_results` instance of `tfp.experimental.mcmc.SequentialMonteCarloResults`.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]