错误(theano.gof.opt):由于:constant_folding引起的优化失败



在神经网络和深度学习中,有一个名为network3的对象(这是一个PY文件,为Python 2.7和Theano 0.7编写)。我对其进行了修改,以使用Python 3.6和Theano 1.0.3运行。但是,当我运行以下代码时:

import network3
from network3 import Network
from network3 import ConvPoolLayer , FullyConnectedLayer , SoftmaxLayer
training_data , validation_data , test_data = network3.load_data_shared()
mini_batch_size = 10
net = Network([FullyConnectedLayer(n_in=784, n_out=100),
               SoftmaxLayer(n_in=100, n_out=10)], mini_batch_size)
net.SGD(training_data , 60, mini_batch_size , 0.1, validation_data , test_data)

它返回了许多具有类似模式的错误:

错误(theano.gof.opt):出现的优化失败:constant_folding

错误(theano.gof.opt):节点:makeVector {dtype ='int64'}(tensorConstant {10},tensorConstant {100})

attributeError:模块'numpy.core.multiarray'没有属性'_get_ndarray_c_version'

然后输出的最后一段是:

attributeError :('编译节点时发生以下错误', Elemwise{Composite{(i0 * (i1 + i2))}}(TensorConstant{10}, TensorConstant{1}, <TensorType(int64, scalar)>),' n'," module'numpy.core.multiarray'没有属性'_get_ndarray_c_version'")

>

我认为第1379行引起了错误:

   1298                                  libraries=self.libraries(),
   1299                                  header_dirs=self.header_dirs(),
-> 1300                                  c_compiler=self.c_compiler(),
   1301                                  )
   1302 
~AppDataLocalContinuumAnaconda3libsite-packagestheanogofcc.py in cmodule_key_(self, fgraph, no_recycling, compile_args, libraries, header_dirs, insert_config_hash, c_compiler)
   1377         # DynamicModule always add the include <numpy/arrayobject.h>
   1378         sig.append('NPY_ABI_VERSION=0x%X' %
-> 1379                    np.core.multiarray._get_ndarray_c_version())
   1380         if c_compiler:
   1381             sig.append('c_compiler_str=' + c_compiler.version_str())
AttributeError: ('The following error happened while compiling the node', Elemwise{Composite{(i0 * (i1 + i2))}}(TensorConstant{10}, TensorConstant{1}, <TensorType(int64, scalar)>), 'n', "module 'numpy.core.multiarray' has no attribute '_get_ndarray_c_version'")

我已经搜索了这些问题,但找不到相关解决方案。你能帮忙吗?

预先感谢。

您的numpy版本是什么?打开Python终端并运行以下行from numpy import __version__,然后运行print(__version__)。在我使用此功能的numpy版本(1.14.2)中,定义很好。

有时包装更新可以贬值甚至删除功能,但也提出了一个新功能来替换旧功能。我不知道是否是这种情况,但总是意识到这种可能性。

最新更新