【问题标题】:Error following first Theano program example第一个 Theano 程序示例后出错
【发布时间】:2015-02-04 10:39:59
【问题描述】:

我对 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相关,但事实并非如此。请帮忙。

【问题讨论】:

    标签: theano


    【解决方案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 无关。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-05-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多