Hi everyone,
I’m reaching out to the forum for some assistance with a PyMC3 model I’m building for a Time-Varying Parameter Vector Autoregression (TVP-PVAR) analysis. I’m encountering a convergence warning and a Theano compilation error, and I’d appreciate any insights or suggestions you might have.
Errors:
- Convergence Warning: I’m getting a
ConvergenceWarning
related to the iterative imputation process used for handling missing values in my data. The warning suggests that the imputation might not have fully converged within the set maximum iterations.[IterativeImputer] Early stopping criterion not reached.
- Theano Compilation Error: Following the convergence warning, I encounter a Theano compilation error with a message about exceeding the maximum bracket nesting level.
Compilation failed (return status=1): /Users//.theano/compiledir_macOS-14.5-arm64-arm-64bit-arm-3.11.8-64/tmpenzneiyk/mod.cpp:72300:32: fatal error: bracket nesting level exceeded maximum of 256.
Code Snippet:
# code deleted at the request of the author/original poster
other code
System Information:
- Python version: (mention your Python version)
- PyMC3 version: 3.11.4(
- Theano version: latest
*Aesera version: latest - OS: macos
Questions:
- How can I effectively address the convergence warning and ensure the iterative imputation process converges adequately?
- Are there any strategies to handle the Theano compilation error related to the bracket nesting level, particularly if it’s caused by the model complexity?
I’ve searched online for solutions, but haven’t found a definitive fix for this specific combination of errors. Any guidance or recommendations from the community would be greatly appreciated.
Additional Information:
- I’ve tried increasing the
imputer_max_iter
parameter in thefit_tvp_pvar
function to allow more iterations for imputation. - I’m open to exploring alternative imputation methods like KNN imputation or more advanced techniques if necessary.
I eneded up with this code after trying to solve this error
anaconda3/lib/python3.11/site-packages/sklearn/impute/_iterative.py:801: ConvergenceWarning: [IterativeImputer] Early stopping criterion not reached.
warnings.warn(
Auto-assigning NUTS sampler…
Initializing NUTS using jitter+adapt_diag…You can find the C code in this temporary file: /var/folders/p_/4shh5wgx7vn_sp4_77tp6c7m0000gn/T/theano_compilation_error_0s9f3yfr
Traceback (most recent call last):File ~/anaconda3/lib/python3.11/site-packages/theano/tensor/basic.py:184 in as_tensor_variable
x = [extract_constants(i) for i in x]File ~/anaconda3/lib/python3.11/site-packages/theano/tensor/basic.py:184 in
x = [extract_constants(i) for i in x]File ~/anaconda3/lib/python3.11/site-packages/theano/tensor/basic.py:179 in extract_constants
raise TypeErrorTypeError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
Cell In[2], line 1
model.fit_tvp_pvar(num_iterations=50000, burn=20000, tune=10000, cores=4, imputation_method=‘iterative’, imputer_max_iter=1000)Cell In[1], line 130 in fit_tvp_pvar
trace = pm.sample(num_iterations, tune=tune, cores=cores, return_inferencedata=True)File ~/anaconda3/lib/python3.11/site-packages/pymc3/sampling.py:496 in sample
start_, step = init_nuts(File ~/anaconda3/lib/python3.11/site-packages/pymc3/sampling.py:2187 in init_nuts
step = pm.NUTS(potential=potential, model=model, **kwargs)File ~/anaconda3/lib/python3.11/site-packages/pymc3/step_methods/hmc/nuts.py:168 in init
super().init(vars, **kwargs)File ~/anaconda3/lib/python3.11/site-packages/pymc3/step_methods/hmc/base_hmc.py:88 in init
super().init(vars, blocked=blocked, model=model, dtype=dtype, **theano_kwargs)File ~/anaconda3/lib/python3.11/site-packages/pymc3/step_methods/arraystep.py:254 in init
func = model.logp_dlogp_function(vars, dtype=dtype, **theano_kwargs)File ~/anaconda3/lib/python3.11/site-packages/pymc3/model.py:1001 in logp_dlogp_function
costs = [self.logpt]File ~/anaconda3/lib/python3.11/site-packages/pymc3/model.py:1011 in logpt
logp = tt.sum([tt.sum(factor) for factor in factors])File ~/anaconda3/lib/python3.11/site-packages/theano/tensor/basic.py:3221 in sum
out = elemwise.Sum(axis=axis, dtype=dtype, acc_dtype=acc_dtype)(input)File ~/anaconda3/lib/python3.11/site-packages/theano/graph/op.py:250 in call
node = self.make_node(*inputs, **kwargs)File ~/anaconda3/lib/python3.11/site-packages/theano/tensor/elemwise.py:1925 in make_node
input = as_tensor_variable(input)File ~/anaconda3/lib/python3.11/site-packages/theano/tensor/basic.py:194 in as_tensor_variable
return theano.tensor.opt.MakeVector(dtype)(*x)File ~/anaconda3/lib/python3.11/site-packages/theano/graph/op.py:253 in call
compute_test_value(node)File ~/anaconda3/lib/python3.11/site-packages/theano/graph/op.py:126 in compute_test_value
thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=)File ~/anaconda3/lib/python3.11/site-packages/theano/graph/op.py:634 in make_thunk
return self.make_c_thunk(node, storage_map, compute_map, no_recycling)File ~/anaconda3/lib/python3.11/site-packages/theano/graph/op.py:600 in make_c_thunk
outputs = cl.make_thunk(File ~/anaconda3/lib/python3.11/site-packages/theano/link/c/basic.py:1203 in make_thunk
cthunk, module, in_storage, out_storage, error_storage = self.compile(File ~/anaconda3/lib/python3.11/site-packages/theano/link/c/basic.py:1138 in compile
thunk, module = self.cthunk_factory(File ~/anaconda3/lib/python3.11/site-packages/theano/link/c/basic.py:1634 in cthunk_factory
module = get_module_cache().module_from_key(key=key, lnk=self)File ~/anaconda3/lib/python3.11/site-packages/theano/link/c/cmodule.py:1191 in module_from_key
module = lnk.compile_cmodule(location)File ~/anaconda3/lib/python3.11/site-packages/theano/link/c/basic.py:1543 in compile_cmodule
module = c_compiler.compile_str(File ~/anaconda3/lib/python3.11/site-packages/theano/link/c/cmodule.py:2546 in compile_str
raise Exception(Exception: ('Compilation failed (return status=1): /Users/evangeloss/.theano/compiledir_macOS-14.5-arm64-arm-64bit-arm-3.11.8-64/tmpenzneiyk/mod.cpp:72300:32: fatal error: bracket nesting level exceeded maximum of 256. if (!PyErr_Occurred()) {. ^. /Users/evangeloss/.theano/compiledir_macOS-14.5-arm64-arm-64bit-arm-3.11.8-64/tmpenzneiyk/mod.cpp:72300:32: note: use -fbracket-depth=N to increase maximum nesting level. 1 error generated… ', "FunctionGraph(MakeVector{dtype=‘float64’}(<TensorType(float64, scalar)>, <TensorType(float64, scalar)>, <TensorType(float64, scalar)>, <TensorType(float64, scalar)>, <TensorType(float64, scalar)>, <TensorType(float64, scalar)>, <TensorType(float64, scalar)>, <TensorType(float64, scalar)>,
Thanks in advance for your time and help!
Best regards,
Dimitri