Closed ekvall93 closed 6 years ago
Yikes. I can't see the error that you get.
I did update the pip package online, if you wouldn't mind trying to updating to the 0.2.7 version.
pip install --upgrade coniii
Actually, you should be able to find 0.2.8 for Mac OS.
I was on able to upgrade to Version: 0.2.7, I can try to upgrade soon again If it might help.
My module error disappeared after upgrading. But when running through the guide I get these following error:
AttributeError: 'MCH' object has no attribute 'N'
and
AttributeError: 'int' object has no attribute 'copy'
Sorry, Should be more specific...
In the paragrapgh Monte Carlo histogram (MCH) i got the following error:
AttributeError Traceback (most recent call last)
Hm. This is not good. There must be something I did wrong when debugging because I didn't have any of these problems. Let me run through the usage notebook again and see what happened.
And in the paragrapgh Regularized mean field:
AttributeError Traceback (most recent call last)
Alright
Ok. I think I did it right this time. You should be able to find the working v0.2.9 on PyPI. Thanks for pointing out the problems.
Let me know if you have any more trouble.
I have upgraded to v0.2.9 and indeed the old error is gone. I instead get insertion errors.
AssertionError Traceback (most recent call last)
AssertionError Traceback (most recent call last)
Your first error when calling the MCH solution method is because the ipynb notebook did not update with the pip package. I'm not sure why that is the case, but you can find here in the GitHub the working version. Basically, you want to specify the constraints
kwarg.
estMultipliers = solver.solve(constraints=sisj,maxiter=40,custom_convergence_f=learn_settings)
The usage guide is here: https://github.com/bcdaniels/coniii/blob/master/ipynb/usage_guide.ipynb
As for the second error, I'm a bit puzzled. Could be that multiprocess is not the latest version. I definitely do not have this bug when I run it. If you would try updating multiprocess and let me know if that works, I could then make sure people have the right version installed before running coniii.
I have copy pasted the paragraph for MCH in the user guid to my jupyter, but still the same error.
I have tried updating multiprocesses, I have currently (0.70.5)
Regarding the MCH error, did you specify the constraints argument as in
solver.solve(constraints=sisj,maxiter=40,custom_convergence_f=learn_settings)
?
I'm definitely not getting this error once I've specified that.
Strange, i use the exact same command:
AssertionError Traceback (most recent call last)
Ok. So you don't get the constraints assertion error anymore which is good.
This multiprocess error is a bit more opaque. It might be helpful to know if your multiprocess code works on any simple code like
def f(x):
return np.random.rand()
pool=mp.Pool(mp.cpu_count())
pool.map(f,range(100))
pool.close()
If you really need to sample from the model, I would avoid multiprocess parallelization for now. There is a method in the sampler for regular sampling generate_samples(). I don't think that the interface is set up to make this a simple option with MCH, but you can change the Solver class' generate_samples() method.
I'll put that on the todo list.
So I would actually want to try your MCH model for an experimentell dataset of 50 neurons with activity over time. I there any easy way to fix so the model trains with respect to my experimentell data? I guess it's calc_observables I somehow should calculate for my data right?
But I guess it does not really matter until I get the the MCH to work anyways...
Btw, this work
import multiprocess as mp
def f(x): return np.random.rand() pool=mp.Pool(mp.cpu_count()) pool.map(f,range(100)) pool.close()
I would recommend using the MPF solver first to find an initial set of parameters before running MCH.
The problem right now is that the parallel MCMC sampling using multiprocess is not working for you. I would suggest changing the self.sampler.generate_samples_parallel call on lines 182 and 186 in file solvers.py to self.sampler.generate_samples. This is implemented in samplers.py in the Metropolis class. If you have problems questions about calling it, you can look there.
Of course, this is going to be slower. Generally, N processors will speed up your sampling routine by a factor of N.
I have now changed these two lines two: self.sampler.generate_samples( sample_size, n_iters=burnin, cpucount=self.n_jobs, initial_sample=initialsample) self.sampler.generate_samples( sample_size, n_iters=n_iters, cpucount=self.n_jobs, initial_sample=self.sampler.samples)
But I now get this following error:
TypeError Traceback (most recent call last)
I feels that these errors are a bottomless pit. I'm the first one that get these kinds of error? Should I wait for some update instead of trying to fix one error after the other?'
Have you had any other people trying out the code lately? I might have a software that is not updated or something.
Another thing that yield problems for me is:
Another thing that have been giving mer error is the following:
elif sample_method=='metropolis': self.sampler.theta = multipliers.copy()
self.sampler.generate_samples_parallel( sample_size,
n_iters=burnin,
cpucount=self.n_jobs,
initial_sample=initial_sample )
Where I guess I should change initial_sample=initial_sample -> initial_sample=self.sampler.samples ?
It's when changing this I get this following error:
TypeError Traceback (most recent call last) in () 4 sample_size=100, 5 sample_method='metropolis', ----> 6 mch_approximation=mchApproximation) 7 8 # Define function for changing learning parameters as we converge.
/Users/markusekvall/Desktop/entropy_tool/venv/lib/python2.7/site-packages/coniii/solvers.py in init(self, *args, *kwargs) 545 ------- 546 """ --> 547 super(MCH,self).init(args,**kwargs) 548 assert not self.sampleSize is None, "Must specify sample_size." 549 assert not self.sampleMethod is None, "Must specify sample_method."
TypeError: super(type, obj): obj must be an instance or subtype of type
Really sorry about the errors. Of course, it's hard to know if other people have tried using the package before and just have given up after meeting some errors, so I appreciate that you've contacted us about them. I've been using the package without any problem, but there are bound to be things like system differences and tweaks that I've put in somewhere else that might be taking care of these problems for me elsewhere.
I'm guessing the last error that you are showing me is because you need to kill the kernel and reload the package. Otherwise, the super reference won't work properly.
I can write up an update that adds functionality for switching to a non-parallelized sampler pretty quickly, but hung up on a few other projects with priority right now. I'd have to get back to you sometime this weekend probably.
If you don't mind digging into the source code a bit, adjusting the code to handle the non-parallelized code might not take too long.
I fully understand!
I will play around a bit and see if it works out.
Cheers
How you found any buggs with the parallel_sampling yet?
I'm currently running the vanilla sampling method, but it seems not to be plausible for system with for example n=159.
I have two other questions as well:
1) The Is the mch_approximation function the histogram re-weighting part?
2) What kind of correaltion do you use in pair_corr? Why not use for example np.cov()?
Thanks for answers
No, I haven't. I am looking into updating the code to use regular sampling. I will see if I can replicate your error with my Mac today. (Also it's possible that your bug has been addressed in a newer version of pathos or on their issue forum: https://github.com/uqfoundation/pathos)
Ok, I have no problem with the latest version on my Mac.
I was looking at your error again, and it looks like multiprocess is saying there is some timeout problem. Just to check, you're using conda and pip installing multiprocess?
Thank you for the answers!
My multiprocess works now! I'm not sure what fixed the bug, but it might be the newer versions of pathos that fixed it.
Do you have any other tip on speeding up the simulation? Just by following the article by Tkacïk he claims that the can run the simulation for around 150 neurons in a couple of minutes. When I run yours it seems that I have to runt it for way longer? Do I implement some of the parameters wrong?
For 30 neurons I set the following parameters:
solver = MCH(n,calc_observables=calc_observables, sample_size=6000, sample_method='metropolis', mch_approximation=mchApproximation)
stMultipliers, sample_MCH = solver.solve(constraints=sisj,n_iters=300, burnin=300,maxiter=10,custom_convergence_f=learn_settings,disp=False)
And it will take approxamately 1,5h...
I'm glad you figured that out.
I would guess that their sampling routine is highly optimized and that they may have different settings. The initial solution is also very important.
I'm going to close this issue and open up a feature request for you. We can discuss there.
I get the following error after implementing the innit code, and I cannot find a file with the name ising_eqn either...