@@ -123,11 +123,15 @@ def sample(draws=500, step=None, init='auto', n_init=200000, start=None,
123
123
Initialization method to use for auto-assigned NUTS samplers.
124
124
125
125
* auto : Choose a default initialization method automatically.
126
- Currently, this is `'advi +adapt_diag'`, but this can change in
126
+ Currently, this is `'unif +adapt_diag'`, but this can change in
127
127
the future. If you depend on the exact behaviour, choose an
128
128
initialization method explicitly.
129
129
* adapt_diag : Start with a identity mass matrix and then adapt
130
- a diagonal based on the variance of the tuning samples.
130
+ a diagonal based on the variance of the tuning samples. All
131
+ chains use the test value (usually the prior mean) as starting
132
+ point.
133
+ * jitter+adapt_diag : Same as `adapt_diag`, but add uniform jitter
134
+ in [-1, 1] to the starting point in each chain.
131
135
* advi+adapt_diag : Run ADVI and then adapt the resulting diagonal
132
136
mass matrix based on the sample variance of the tuning samples.
133
137
* advi+adapt_diag_grad : Run ADVI and then adapt the resulting
@@ -695,11 +699,15 @@ def init_nuts(init='auto', njobs=1, n_init=500000, model=None,
695
699
Initialization method to use.
696
700
697
701
* auto : Choose a default initialization method automatically.
698
- Currently, this is `'advi +adapt_diag'`, but this can change in
702
+ Currently, this is `'unif +adapt_diag'`, but this can change in
699
703
the future. If you depend on the exact behaviour, choose an
700
704
initialization method explicitly.
701
705
* adapt_diag : Start with a identity mass matrix and then adapt
702
- a diagonal based on the variance of the tuning samples.
706
+ a diagonal based on the variance of the tuning samples. All
707
+ chains use the test value (usually the prior mean) as starting
708
+ point.
709
+ * jitter+adapt_diag : Same as `adapt_diag`, but add uniform jitter
710
+ in [-1, 1] to the starting point in each chain.
703
711
* advi+adapt_diag : Run ADVI and then adapt the resulting diagonal
704
712
mass matrix based on the sample variance of the tuning samples.
705
713
* advi+adapt_diag_grad : Run ADVI and then adapt the resulting
@@ -746,7 +754,7 @@ def init_nuts(init='auto', njobs=1, n_init=500000, model=None,
746
754
init = init .lower ()
747
755
748
756
if init == 'auto' :
749
- init = 'advi +adapt_diag'
757
+ init = 'jitter +adapt_diag'
750
758
751
759
pm ._log .info ('Initializing NUTS using {}...' .format (init ))
752
760
@@ -767,6 +775,19 @@ def init_nuts(init='auto', njobs=1, n_init=500000, model=None,
767
775
model .ndim , mean , var , 10 )
768
776
if njobs == 1 :
769
777
start = start [0 ]
778
+ elif init == 'jitter+adapt_diag' :
779
+ start = []
780
+ for _ in range (njobs ):
781
+ mean = {var : val .copy () for var , val in model .test_point .items ()}
782
+ for val in mean .values ():
783
+ val [...] += 2 * np .random .rand (* val .shape ) - 1
784
+ start .append (mean )
785
+ mean = np .mean ([model .dict_to_array (vals ) for vals in start ], axis = 0 )
786
+ var = np .ones_like (mean )
787
+ potential = quadpotential .QuadPotentialDiagAdapt (
788
+ model .ndim , mean , var , 10 )
789
+ if njobs == 1 :
790
+ start = start [0 ]
770
791
elif init == 'advi+adapt_diag_grad' :
771
792
approx = pm .fit (
772
793
random_seed = random_seed ,
0 commit comments