Skip to content

Commit 9faaa72

Browse files
committed
set maxcor to max(5, floor(N / 1.9)). max=1 will cause error
1 parent a77f2c8 commit 9faaa72

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pymc_experimental/inference/pathfinder/pathfinder.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ def multipath_pathfinder(
780780

781781
def fit_pathfinder(
782782
model=None,
783-
num_paths: int = 6, # I
783+
num_paths: int = 8, # I
784784
num_draws: int = 1000, # R
785785
num_draws_per_path: int = 1000, # M
786786
maxcor: int | None = None, # J
@@ -809,13 +809,13 @@ def fit_pathfinder(
809809
model : pymc.Model
810810
The PyMC model to fit the Pathfinder algorithm to.
811811
num_paths : int
812-
Number of independent paths to run in the Pathfinder algorithm. (default is 6)
812+
Number of independent paths to run in the Pathfinder algorithm. (default is 8)
813813
num_draws : int, optional
814814
Total number of samples to draw from the fitted approximation (default is 1000).
815815
num_draws_per_path : int, optional
816816
Number of samples to draw per path (default is 1000).
817817
maxcor : int, optional
818-
Maximum number of variable metric corrections used to define the limited memory matrix (default is None). If None, maxcor is set to int(floor(N / 1.9)).
818+
Maximum number of variable metric corrections used to define the limited memory matrix (default is None). If None, maxcor is set to int(floor(N / 1.9)) or 5 whichever is greater.
819819
maxiter : int, optional
820820
Maximum number of iterations for the L-BFGS optimisation (default is 1000).
821821
ftol : float, optional
@@ -857,6 +857,7 @@ def fit_pathfinder(
857857
N = DictToArrayBijection.map(model.initial_point()).data.shape[0]
858858
if maxcor is None:
859859
maxcor = np.floor(N / 1.9).astype(np.int32)
860+
maxcor = max(maxcor, 5)
860861

861862
if inference_backend == "pymc":
862863
pathfinder_samples = multipath_pathfinder(

0 commit comments

Comments
 (0)