首先是Theano程序示例后出错

时间:2015-01-29 14:18:28

标签: theano

我对theano完全陌生,并按照这个简单的介绍练习到这里找到的theano:http://deeplearning.net/software/theano/introduction.html#introduction

这个想法是简单地声明一些张量变量并将它们包装在一个函数中,这是你可以用theano做的最简单的事情

确切的代码是:

import theano
from theano import tensor

# declare two symbolic floating-point scalars
a = tensor.dscalar()
b = tensor.dscalar()

# create a simple expression
c = a + b

# convert the expression into a callable object that takes (a,b)
# values as input and computes a value for c
f = theano.function([a,b], c)

# bind 1.5 to 'a', 2.5 to 'b', and evaluate 'c'
assert 4.0 == f(1.5, 2.5)

然而,我得到了这个追溯:

Traceback (most recent call last):
  File "test.py", line 13, in <module>
    f = theano.function([a,b], c)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/compile/function.py", line 223, in function
    profile=profile)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/compile/pfunc.py", line 512, in pfunc
    on_unused_input=on_unused_input)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/compile/function_module.py", line 1312, in orig_function
    defaults)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/compile/function_module.py", line 1181, in create
    _fn, _i, _o = self.linker.make_thunk(input_storage=input_storage_lists)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/link.py", line 434, in make_thunk
    output_storage=output_storage)[:3]
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/vm.py", line 847, in make_all
    no_recycling))
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/op.py", line 606, in make_thunk
    output_storage=node_output_storage)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/cc.py", line 948, in make_thunk
    keep_lock=keep_lock)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/cc.py", line 891, in __compile__
    keep_lock=keep_lock)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/cc.py", line 1314, in cthunk_factory
    key = self.cmodule_key()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/cc.py", line 1032, in cmodule_key
    c_compiler=self.c_compiler(),
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/cc.py", line 1090, in cmodule_key_
    sig.append('md5:' + theano.configparser.get_config_md5())
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/configparser.py", line 146, in get_config_md5
    ['%s = %s' % (cv.fullname, cv.__get__()) for cv in all_opts]))
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/configparser.py", line 146, in <listcomp>
    ['%s = %s' % (cv.fullname, cv.__get__()) for cv in all_opts]))
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/configparser.py", line 273, in __get__
    val_str = self.default()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/tensor/blas.py", line 282, in default_blas_ldflags
    if GCC_compiler.try_flags(["-lblas"]):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/cmodule.py", line 1852, in try_flags
    flags=flag_list, try_run=False)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/theano/gof/cmodule.py", line 1799, in try_compile_tmp
    os.write(fd, src_code)
TypeError: ('The following error happened while compiling the node', Elemwise{add,no_inplace}(<TensorType(float64, scalar)>, <TensorType(float64, scalar)>), '\n', "'str' does not support the buffer interface")

我唯一的想法是它可能与python3相关,但不应该是这种情况。请帮忙。

2 个答案:

答案 0 :(得分:1)

Theano代码库不能用于python2和python3的开箱即用。它需要转换。这是在Theano安装期间完成的。通过pip安装时,会自动完成。如果您克隆/下载了源代码,则需要使用以下命令安装它:

python setup.py install

这是一张包含更多信息的Theano门票:

https://github.com/Theano/Theano/issues/2317

此外,对于python 3支持,您应该使用开发版本行的另一个答案:

pip3 install --upgrade --no-deps git+git://github.com/Theano/Theano.git

但这与BLAS有关,因为它是写的。

答案 1 :(得分:0)

问题不包括最新版本的theano中的BLAS。拉出最新版本时解决了:

pip3 install --upgrade --no-deps git+git://github.com/Theano/Theano.git