pymc3 不工作,使用 Anaconda3 出现 nan 和 none 类型错误
pymc3 not working, getting nan and none type errors using Anaconda3
编辑:在下面的答案中找到了解决方案。把问题留给可能有同样问题的其他人。
我刚刚安装了 pymc3,它只 'partially' 对我有用。我在 windows 的 64 位安装上使用 Anaconda,但我认为这不是问题所在(即,我认为问题不是需要切换到 32 位 anaconda)。
各种例子都不适合我,所以我试着完成这个例子:
http://docs.pymc.io/notebooks/getting_started.html#A-Motivating-Example:-Linear-Regression
一切正常,直到:
with basic_model:
# draw 500 posterior samples
trace = pm.sample(500)
那时,我收到一个错误。编辑:我确实有理由相信它是 loky,因为我通过重新安装 theanos 和其他东西得到了进一步的发展。但我仍然得到这个:
C:\Users\Yurik\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Running on PyMC3 v3.4.1
WARNING (theano.gof.compilelock): Overriding existing lock by dead process '26576' (I am process '27640')
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [sigma_log__, beta, alpha]
Traceback (most recent call last):
File "<ipython-input-1-1ef2ccded6b8>", line 1, in <module>
runfile('C:/Users/Yurik/.spyder-py3/temp.py', wdir='C:/Users/Yurik/.spyder-py3')
File "C:\Users\Yurik\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Yurik/.spyder-py3/temp.py", line 57, in <module>
trace = pm.sample(500)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\pymc3\sampling.py", line 442, in sample
trace = _mp_sample(**sample_args)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\pymc3\sampling.py", line 982, in _mp_sample
traces = Parallel(n_jobs=cores, mmap_mode=None)(jobs)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\parallel.py", line 962, in __call__
self.retrieve()
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\parallel.py", line 865, in retrieve
self._output.extend(job.get(timeout=self.timeout))
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\_parallel_backends.py", line 515, in wrap_future_result
return future.result(timeout=timeout)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\externals\loky\_base.py", line 431, in result
return self.__get_result()
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\externals\loky\_base.py", line 382, in __get_result
raise self._exception
BrokenProcessPool: A process in the executor was terminated abruptly while the future was running or pending.
我终于明白了!跟踪函数后,我注意到 loky 正在获取 cores = None,并且有一个可选参数。因此,该示例需要在 pm.sample 的参数中包含 cores = 1(或类似的),然后才能正常工作!喜欢下面
with basic_model:
# draw 500 posterior samples
trace = pm.sample(500, cores=1)
(尽管值得注意的是我需要安装/重新安装一些依赖项,theanos 和 mw64 或类似的东西,甚至在我到达这一点之前)
编辑:在下面的答案中找到了解决方案。把问题留给可能有同样问题的其他人。
我刚刚安装了 pymc3,它只 'partially' 对我有用。我在 windows 的 64 位安装上使用 Anaconda,但我认为这不是问题所在(即,我认为问题不是需要切换到 32 位 anaconda)。
各种例子都不适合我,所以我试着完成这个例子: http://docs.pymc.io/notebooks/getting_started.html#A-Motivating-Example:-Linear-Regression
一切正常,直到:
with basic_model:
# draw 500 posterior samples
trace = pm.sample(500)
那时,我收到一个错误。编辑:我确实有理由相信它是 loky,因为我通过重新安装 theanos 和其他东西得到了进一步的发展。但我仍然得到这个:
C:\Users\Yurik\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Running on PyMC3 v3.4.1
WARNING (theano.gof.compilelock): Overriding existing lock by dead process '26576' (I am process '27640')
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [sigma_log__, beta, alpha]
Traceback (most recent call last):
File "<ipython-input-1-1ef2ccded6b8>", line 1, in <module>
runfile('C:/Users/Yurik/.spyder-py3/temp.py', wdir='C:/Users/Yurik/.spyder-py3')
File "C:\Users\Yurik\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Yurik/.spyder-py3/temp.py", line 57, in <module>
trace = pm.sample(500)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\pymc3\sampling.py", line 442, in sample
trace = _mp_sample(**sample_args)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\pymc3\sampling.py", line 982, in _mp_sample
traces = Parallel(n_jobs=cores, mmap_mode=None)(jobs)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\parallel.py", line 962, in __call__
self.retrieve()
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\parallel.py", line 865, in retrieve
self._output.extend(job.get(timeout=self.timeout))
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\_parallel_backends.py", line 515, in wrap_future_result
return future.result(timeout=timeout)
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\externals\loky\_base.py", line 431, in result
return self.__get_result()
File "C:\Users\Yurik\Anaconda3\lib\site-packages\joblib\externals\loky\_base.py", line 382, in __get_result
raise self._exception
BrokenProcessPool: A process in the executor was terminated abruptly while the future was running or pending.
我终于明白了!跟踪函数后,我注意到 loky 正在获取 cores = None,并且有一个可选参数。因此,该示例需要在 pm.sample 的参数中包含 cores = 1(或类似的),然后才能正常工作!喜欢下面
with basic_model:
# draw 500 posterior samples
trace = pm.sample(500, cores=1)
(尽管值得注意的是我需要安装/重新安装一些依赖项,theanos 和 mw64 或类似的东西,甚至在我到达这一点之前)