首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PyMC3 & Theano - Theano代码在pymc3导入后停止工作

PyMC3 & Theano - Theano代码在pymc3导入后停止工作
EN

Stack Overflow用户
提问于 2015-05-14 11:21:04
回答 2查看 2.1K关注 0票数 10

一些简单的theano代码工作得很好,当我导入pymc3时,停止工作

在这里,为了重现错误,一些片段:

代码语言:javascript
复制
#Initial Theano Code (this works)    
import theano.tensor as tsr

x = tsr.dscalar('x')
y = tsr.dscalar('y')
z = x + y

#Snippet 1
import pymc3 as pm
import theano.tensor as tsr

x = tsr.dscalar('x')
y = tsr.dscalar('y')
z = x + y

#Snippet 2
import theano.tensor as tsr
import pymc3 as pm

x = tsr.dscalar('x')
y = tsr.dscalar('y')
z = x + y

#Snippet 3
import pymc3 as pm

x = pm.theano.tensor.dscalar('x')
y = pm.theano.tensor.dscalar('y')
z = x + y

对于前面的每个片段,我得到以下错误:

代码语言:javascript
复制
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/Users/tom/anaconda/lib/python3.4/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
    516                 try:
--> 517                     storage_map[ins] = [self._get_test_value(ins)]
    518                     compute_map[ins] = [True]

/Users/tom/anaconda/lib/python3.4/site-packages/theano/gof/op.py in _get_test_value(cls, v)
    478 
--> 479         raise AttributeError('%s has no test value' % v)
    480 

AttributeError: x has no test value

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-2-ef8582b040f8> in <module>()
      3 x = pm.theano.tensor.dscalar('x')
      4 y = pm.theano.tensor.dscalar('y')
----> 5 z = x + y

/Users/tom/anaconda/lib/python3.4/site-packages/theano/tensor/var.py in __add__(self, other)
    126     def __add__(self, other):
    127         try:
--> 128             return theano.tensor.basic.add(self, other)
    129         # We should catch the minimum number of exception here.
    130         # Otherwise this will convert error when Theano flags

/Users/tom/anaconda/lib/python3.4/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
    523                         run_perform = False
    524                     elif config.compute_test_value == 'raise':
--> 525                         raise ValueError('Cannot compute test value: input %i (%s) of Op %s missing default value' % (i, ins, node))
    526                     elif config.compute_test_value == 'ignore':
    527                         # silently skip test

ValueError: Cannot compute test value: input 0 (x) of Op Elemwise{add,no_inplace}(x, y) missing default value

有什么想法吗?提前感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-05-14 15:49:11

我认为这与pymc3设置theano.config.compute_test_value = 'raise'https://github.com/pymc-devs/pymc3/blob/master/pymc3/model.py#L395有关

您可以显式地将theano.config.compute_test_value设置为'ignore'以消除错误。

票数 10
EN

Stack Overflow用户

发布于 2016-08-15 02:31:58

建议的解决方案这里的持续时间比设置标志稍长一些。在shell类型中:

代码语言:javascript
复制
theano-cache purge
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30236070

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档