New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Odd behaviour in v2.3.4 #663
Comments
Actually, I get a worse result than this. I get segmentation faults after trying to run the code a few times. I can narrow it to an even simpler case: N = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,]
S = [ 1, 5, 10, 15, 14, 16, 17, 20, 20, 24, 33, 50, 49]
pymc.Binomial('S', N, 0.5, S, observed=True) which yields python(45269,0x7fff7d1b1300) malloc: *** error for object 0x1020139d8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
/Users/fonnescj/anaconda3/envs/py3/bin/python.app: line 3: 45269 Abort trap: 6 /Users/fonnescj/anaconda3/envs/py3/python.app/Contents/MacOS/python "$@" It has something to do with the list structure, as running the same data but iterating over the scalar values does not replicate the behavior. |
Can you replicate the problem if you pass flat arrays for S and N? The PyMC log-likelihoods aren't really built to handle multidimensional values. |
OK, so there are at least two separate things going on here. First, I ran your code and got the same segmentation fault. After running inside a loop, I find the problem occurs after around 5-11 iterations. Sometimes, however, the code won't raise an error but will just stop before completion. These could be two different things but I think it's likely they are the same, or at least related. Making p an array of the same length as N and S fixes both of these issues. The error I posted is somewhat different, and as you say appears to be caused by passing multi-dimensional arrays to PyMC. It seems to be assigning observations to the wrong parameters, such that sometimes the value of S is assigned the wrong corresponding N parameter. When this causes s>n, it throws out the pymc.Node.ZeroProbability exception. Based on this, would you recommend flattening ALL arrays passed to PyMC objects? |
I always recommend using flat data structures in PyMC, and slicing the values that you need when you need them. I haven't yet tracked down what is causing either of the issues, however, so I can't say much more than that at this point. I know that PyMC will resize I'm pretty sure the issue occurs outside of the Fortran, however, because when I call
This is good news, since it should be easier to debug. |
Something crazy going on here:
|
OK, I think I got it. Please test the current 2.3 branch and see if the problem persists. |
Do you know the conda/brew/pip command to do this? (sorry, complete amateur). |
The easiest way is this:
|
Seems to do the trick! |
I'm using version 2.3.4 (as recommended in another issue), and I'm getting some really odd behaviour when trying to create a simple model with a non-trivial number of data points. Below I've attached some simple code that produces the error:
Sometimes this code will run with no problems, but sometimes I get the following error:
which does not make sense to me since all the values are valid. The probability of encountering an error seems to increase the more times I run the script. Any ideas?
The text was updated successfully, but these errors were encountered: