Makis Kans
Makis Kans

Reputation: 337

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

I'm running this simple example:

import theano
x = theano.tensor.dscalar()
f = theano.function([x], 2*x)
f(4)

and I get:

AttributeError: ('The following error happened while compiling the node', Elemwise{mul,no_inplace}(TensorConstant{2.0}, <TensorType(float64, scalar)>), '\n', "module 'numpy.core.multiarray' has no attribute '_get_ndarray_c_version'")

I though it must be a numpy error, so I try to update but I have the latest version as far as I know:

import numpy

numpy.version.version
'1.16.2'

I'm running all this in spyder but that seems to be irrelevant since I get the same error in python interpreter

Upvotes: 8

Views: 8623

Answers (2)

merv
merv

Reputation: 76850

This is a known bug presumably caused by changes introduced in NumPy. A fix for this was introduced in Theano v1.0.4. So, either you need to upgrade to at least that version of Theano, or downgrade NumPy to below v1.16.

Note that at the moment (25 July 2019) only Conda Forge has Theano v1.0.4, whereas Anaconda has v1.0.3. So you need to run

conda install -c conda-forge theano=1.0.4

Otherwise, the NumPy downgrade is

conda install numpy=1.15

Upvotes: 10

么么么么哒
么么么么哒

Reputation: 31

Go to the

Anaconda3\pkgs\theano-1.0.3-py37_0\Lib\site-packages\theano\gof

open cc.py

go to line 1376

comment these code:

sig.append('NPY_ABI_VERSION=0x%X' %
        np.core.multiarray._get_ndarray_c_version())

like this

For more details you can Refer:

https://github.com/MichalDanielDobrzanski/DeepLearningPython35/issues/20

https://www.wandouip.com/t5i268914/

Upvotes: 3

Related Questions