错误(theano.gof.opt):由于以下原因导致优化失败:constant_folding [英] ERROR (theano.gof.opt): Optimization failure due to: constant_folding

查看:685
本文介绍了错误(theano.gof.opt):由于以下原因导致优化失败:constant_folding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In Neural Networks and Deep Learning, there's an object called network3 (which is a PY file, written for python 2.7 and theano 0.7). I modified it to run with python 3.6 and theano 1.0.3. However, when I run the following code:

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)

它返回了很多类似模式的错误:

It returned a lot of errors that have similar pattern like this:


错误(theano.gof.opt):优化失败归因于:constant_folding

ERROR (theano.gof.opt): Optimization failure due to: constant_folding

ERROR(theano.gof .opt):节点:MakeVector {dtype ='int64'}(TensorConstant {10},TensorConstant {100})

ERROR (theano.gof.opt): node: MakeVector{dtype='int64'}(TensorConstant{10}, TensorConstant{100})

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

AttributeError: module 'numpy.core.multiarray' has no attribute '_get_ndarray_c_version'

然后输出中的最后一段是:

Then the last paragraph in the output was:


AttributeError:('The following Elemwise {Composite {(i0 *(i1 + i2))}}(TensorConstant {10},TensorConstant {1},< TensorType(int64,标量)> ),'\n',模块'numpy.core.multiarray'没有属性'_get_ndarray_c_version'))

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'")

我认为第1379行导致了错误:

I think line 1379 caused the error:

   1298                                  libraries=self.libraries(),
   1299                                  header_dirs=self.header_dirs(),
-> 1300                                  c_compiler=self.c_compiler(),
   1301                                  )
   1302 

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\theano\gof\cc.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'")

我已经搜索了问题,但找不到相关的解决方案。

I have googled the issues but couldn't find relevant solution. Could you please help?

预先感谢。

推荐答案

是您的numpy版本?打开python终端,然后从numpy import __version __ 运行以下行,然后运行 print(__ version __)。在我使用的此函数的numpy版本( 1.14.2 )中,定义得很好。

What is your numpy version? Open a python terminal and run the following lines from numpy import __version__ and then print(__version__). In the numpy version (1.14.2) that I am using this function is well defined.

有时,程序包更新可以使某个功能贬值,甚至可以删除某个功能,但还可以提出一个新功能来替换较旧的功能。我不知道是否是这种情况,但请始终注意这种可能性。

Sometimes a package update can depreciate a function or even remove a function but also propose a new function to replace the older one. I don't know if that is the case but be always aware of this possibility.

这篇关于错误(theano.gof.opt):由于以下原因导致优化失败:constant_folding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆