File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ def fit_dadvi(
29
29
n_draws : int = 1000 ,
30
30
keep_untransformed : bool = False ,
31
31
optimizer_method : minimize_method = "trust-ncg" ,
32
+ use_jacobian : bool = True ,
33
+ use_hessp : bool = True ,
32
34
** minimize_kwargs ,
33
35
) -> az .InferenceData :
34
36
"""
@@ -73,6 +75,12 @@ def fit_dadvi(
73
75
``scipy.optimize.minimize`` function. See the documentation of
74
76
that function for details.
75
77
78
+ use_jacobian:
79
+ If True, pass the Jacobian function to `scipy.optimize.minimize`.
80
+
81
+ use_hessp:
82
+ If True, pass the hessian vector product to `scipy.optimize.minimize`.
83
+
76
84
Returns
77
85
-------
78
86
:class:`~arviz.InferenceData`
@@ -106,12 +114,18 @@ def fit_dadvi(
106
114
compute_hess = False ,
107
115
)
108
116
117
+ derivative_kwargs = {}
118
+
119
+ if use_jacobian :
120
+ derivative_kwargs ["jac" ] = True
121
+ if use_hessp :
122
+ derivative_kwargs ["hessp" ] = f_hessp
123
+
109
124
result = minimize (
110
125
f_fused ,
111
126
np .zeros (2 * n_params ),
112
- jac = True ,
113
127
method = optimizer_method ,
114
- hessp = f_hessp ,
128
+ ** derivative_kwargs ,
115
129
** minimize_kwargs ,
116
130
)
117
131
You can’t perform that action at this time.
0 commit comments