Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 575
Makis Kans Avatar asked Mar 07 '19 14:03

Makis Kans


2 Answers

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
like image 64
merv Avatar answered Nov 06 '22 01:11

merv


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/

like image 29
么么么么哒 Avatar answered Nov 06 '22 03:11

么么么么哒