tfp.mcmc.even_odd_swap_proposal_fn
Stay organized with collections
Save and categorize content based on your preferences.
Make a deterministic swap proposal function, alternating even/odd swaps.
tfp.mcmc.even_odd_swap_proposal_fn(
swap_frequency, name=None
)
This proposal function swaps deterministically swap_frequency
fraction of
the time, alternating even and odd parity.
This was shown in [2] to mix better than random schemes.
Contrast this with default_swap_proposal_fn
, which swaps randomly with
probability prob_swap
.
swap_fn = even_odd_swap_proposal_fn(swap_frequency=1)
even_odd_swap_proposal_fn(num_replica=4, step_count=0)
==> [1, 0, 3, 2] # Swap 0 <--> 1 and 2 <--> 3, even parity.
even_odd_swap_proposal_fn(num_replica=4, step_count=1)
==> [0, 2, 1, 3] # Swap 1 <--> 2, odd parity.
Args |
swap_frequency
|
Scalar Tensor in [0, 1] giving the frequency of swaps.
Swaps will occur, with alternating parity, every N steps, where
N = 1 / swap_frequency .
|
name
|
Python str name given to ops created by this function.
Default value: 'even_odd_swaps' .
|
Returns |
default_swap_proposal_fn_
|
Python callable which take a number of
replicas (a Python integer), and integer Tensor batch_shape , a
step_count , a seed , and returns swaps , a shape
[num_replica] + batch_shape Tensor , where axis 0 indexes
"one-time swaps", i.e., such that (if rank(swaps) == 1 ,
range(num_replicas) == tf.gather(swaps, swaps) .
|
References
[1]: S. Syed, A. Bouchard-Cote G. Deligiannidis, A. Doucet
Non-Reversible Parallel Tempering: a Scalable Highly Parallel MCMC Scheme
https://arxiv.org/abs/1905.02939
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[null,null,["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.mcmc.even_odd_swap_proposal_fn\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/mcmc/replica_exchange_mc.py#L193-L282) |\n\nMake a deterministic swap proposal function, alternating even/odd swaps. \n\n tfp.mcmc.even_odd_swap_proposal_fn(\n swap_frequency, name=None\n )\n\nThis proposal function swaps deterministically `swap_frequency` fraction of\nthe time, alternating even and odd parity.\nThis was shown in \\[2\\] to mix better than random schemes.\n\nContrast this with `default_swap_proposal_fn`, which swaps randomly with\nprobability `prob_swap`. \n\n swap_fn = even_odd_swap_proposal_fn(swap_frequency=1)\n\n even_odd_swap_proposal_fn(num_replica=4, step_count=0)\n ==\u003e [1, 0, 3, 2] # Swap 0 \u003c--\u003e 1 and 2 \u003c--\u003e 3, even parity.\n\n even_odd_swap_proposal_fn(num_replica=4, step_count=1)\n ==\u003e [0, 2, 1, 3] # Swap 1 \u003c--\u003e 2, odd parity.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `swap_frequency` | Scalar `Tensor` in `[0, 1]` giving the frequency of swaps. Swaps will occur, with alternating parity, every `N` steps, where `N = 1 / swap_frequency`. |\n| `name` | Python `str` name given to ops created by this function. Default value: `'even_odd_swaps'`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `default_swap_proposal_fn_` | Python callable which take a number of replicas (a Python integer), and integer `Tensor` `batch_shape`, a `step_count`, a `seed`, and returns `swaps`, a shape `[num_replica] + batch_shape` `Tensor`, where axis 0 indexes \"one-time swaps\", i.e., such that (if `rank(swaps) == 1`, `range(num_replicas) == tf.gather(swaps, swaps)`. |\n\n\u003cbr /\u003e\n\n#### References\n\n\\[1\\]: S. Syed, A. Bouchard-Cote G. Deligiannidis, A. Doucet\nNon-Reversible Parallel Tempering: a Scalable Highly Parallel MCMC Scheme\n\u003chttps://arxiv.org/abs/1905.02939\u003e"]]