Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyMC3&;Theano-工作的Theano代码在pymc3导入后停止工作_Python_Theano_Pymc3 - Fatal编程技术网

Python PyMC3&;Theano-工作的Theano代码在pymc3导入后停止工作

Python PyMC3&;Theano-工作的Theano代码在pymc3导入后停止工作,python,theano,pymc3,Python,Theano,Pymc3,一些简单的theano代码可以完美地工作,当我导入pymc3时停止工作 以下是一些复制错误的示例: #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')

一些简单的theano代码可以完美地工作,当我导入pymc3时停止工作

以下是一些复制错误的示例:

#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
对于前面的每个代码段,我都会得到以下错误:

---------------------------------------------------------------------------
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
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
/Users/tom/anaconda/lib/python3.4/site-packages/theano/gof/op.py in_uuuucall_uuu(self,*输入,**kwargs)
516试试:
-->517存储映射[ins]=[自身获取测试值(ins)]
518计算映射[ins]=[True]
/Users/tom/anaconda/lib/python3.4/site-packages/theano/gof/op.py in\u get\u test\u value(cls,v)
478
-->479 raise AttributeError(“%s”没有测试值“%v”)
480
AttributeError:x没有测试值
在处理上述异常期间,发生了另一个异常:
ValueError回溯(最近一次调用上次)
在()
3x=pm.theano.tensor.dscalar('x')
4y=pm.theano.tensor.dscalar('y')
---->5Z=x+y
/Users/tom/anaconda/lib/python3.4/site-packages/theano/tensor/var.py in\uuuu添加(self,other)
126定义添加(自身、其他):
127尝试:
-->128返回theano.tensor.basic.add(self,other)
129#我们应该在这里捕获最少数量的异常。
130#否则这将在没有标志时转换错误
/Users/tom/anaconda/lib/python3.4/site-packages/theano/gof/op.py in_uuuucall_uuu(self,*输入,**kwargs)
523运行\执行=错误
524 elif config.compute_test_value=='raise':
-->525 raise VALUERROR('无法计算测试值:操作%s的输入%i(%s)缺少默认值'%(i,ins,node))
526 elif config.compute_test_value==‘忽略’:
527#自动跳过测试
ValueError:无法计算测试值:Op Elemwise{add,no_inplace}(x,y)的输入0(x)缺少默认值
有什么想法吗?
提前感谢

我认为这与
pymc3
设置
theano.config.compute\u test\u value='raise'
有关:

您可以显式地将
theano.config.compute\u test\u值设置回
'ignore'
,以消除错误。

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

theano-cache purge