在神经网络与深度学习中,有一个名为network3的对象(它是为python2.7和theano 0.7编写的PY文件)。我将其修改为使用python3.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 64’}(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',模块'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
~\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'")我搜索了这些问题,但没有找到相关的解决方案。你能帮忙吗?
提前谢谢。
发布于 2019-03-08 13:46:28
你的粗野版是什么?打开python终端,运行以下行from numpy import __version__,然后运行print(__version__)。在我使用的numpy版本(1.14.2)中,这个函数是很好定义的。
有时,包更新可以使一个函数贬值,甚至删除一个函数,但也可以提出一个新的函数来替换旧的函数。我不知道是否是这样,但要时刻注意到这种可能性。
https://stackoverflow.com/questions/55024382
复制相似问题