I am trying to run the installation test of the Theano with the following code:
import theano
theano.test()
However, I would see the following error corresponding to blas.py:
/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/theano/tensor/blas.py in default_blas_ldflags()
301 try:
302 #if numpy was linked with library that are not installed, we can't reuse them.
--> 303 if all(not os.path.exists(dir) for dir in numpy.distutils.__config__.blas_opt_info['library_dirs']):
304 return "-lblas"
305 return ' '.join(
AttributeError: 'module' object has no attribute '__config__'
I understand that AttributeError is a famous error and there are questions asked about it, but for Theano the only solution I found on the internet was to add:
import numpy.distutils.config
to the blas.py. However, this does not solve the problem and I am still facing the AttributeError.
This is fixed in Theano development version.
Use one of those 2 command to update Theano depending if the installation is just for your user or for the OS:
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git --user
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
Here is the doc for that update:
http://www.deeplearning.net/software/theano/install.html#bleeding-edge-install-instructions
Related
While running the code az.plot_trace(result_final);
facing the below error
TypeError: expected dtype object, got 'numpy.dtype[float64]'
The above exception was the direct cause of the following exception:
SystemError: CPUDispatcher(<function histogram at 0x00000147106C8B88>) returned a result with an error set
Can you please let me know how to solve this
I suggest upgrading numba to the latest version, e.g. python3 -m pip install numba==[latest version]. This might require a manual update to llmvite as well by doing, python3 -m pip install --ignore-installed llvmlite. Hope that helps!
I met this problem in my machine,and I spent several hours in solving this,I hope it can help others if they meet the same problem.
For Unix: pip install python-gssapi.
For Windows: pip install pywin32.
For more information, check here
In addition, if you get an error about
"attribute error: 'module' object has no attribute 'gssexception'"
, maybe you have installed a wrong gssapi, remove your gssapi firstly(by pip uninstall gssapi) and install gssapi as previous mentioned.
Here is the code:
from pyemd import emd
print("sentence 1:")
print(input_document_lower[0])
print("sentence 2:")
print(input_document_lower[1])
print("similarity:")
model_w2v.wmdistance(input_document_lower[0], input_document_lower[1])
Here's the error:
sentence 1:
incorrect batch number printed primary label pbn
sentence 2:
unconfirmed oos met vial washing qualification sample per
similarity:
ImportErrorTraceback (most recent call last)
<ipython-input-201-50af089a2354> in <module>()
4 print(input_document_lower[1])
5 print("similarity:")
----> 6 model_w2v.wmdistance(input_document_lower[0], input_document_lower[1])
C:\ProgramData\Anaconda2\lib\site-packages\gensim\models\word2vec.pyc in wmdistance(self, document1, document2)
1308 Refer to the documentation for `gensim.models.KeyedVectors.wmdistance`
1309 """
-> 1310 return self.wv.wmdistance(document1, document2)
1311
1312 def most_similar_cosmul(self, positive=None, negative=None, topn=10):
C:\ProgramData\Anaconda2\lib\site-packages\gensim\models\keyedvectors.pyc in wmdistance(self, document1, document2)
386
387 if not PYEMD_EXT:
--> 388 raise ImportError("Please install pyemd Python package to compute WMD.")
389
390 # Remove out-of-vocabulary words.
ImportError: Please install pyemd Python package to compute WMD.
It is being installed properly so I really have no clue as to what is going wrong. Have any of your encountered this?
I had the same error, and for me the solution was to swap:
from gensim.similarities import WmdSimilarity
from pyemd import emd
into
from pyemd import emd
from gensim.similarities import WmdSimilarity
Don't ask me why it works.
Solved this as following -
If your pip install is not working use conda install instead by using this command
conda install -c conda-forge pyemd
I believe that now you have successfully installed pyemd. Now when it comes to thowing error even after importing successfully do as following -
import pyemd before any gensim module. I mean pyemd should be on top.
from pyemd import emd
from gensim.similarities import WmdSimilarity
from gensim.models.doc2vec import LabeledSentence
from gensim.models.doc2vec import TaggedLineDocument
I hope you are done with this concern :)
I had some issues, I installed this package in my virtual env, but it doesn't work. Then I rebooted my computer, and after that it works.
Add the line shown below
global PYEMD_EXT
just above the try:except code block
try:
from pyemd import emd
PYEMD_EXT = True
except ImportError:
PYEMD_EXT = False
Go to the keyedvectors.py file and delete the try catch block.
This:
try:
from pyemd import emd
PYEMD_EXT = True
except ImportError:
PYEMD_EXT = False
Remove the import error prompt
if not PYEMD_EXT:
raise ImportError("Please install pyemd Python package to compute WMD.")
add this
from pyemd import emd
To know more about the bug check, https://github.com/RaRe-Technologies/gensim/pull/2229/files
Even after this code throws an error. One possible problem is you'll running in jupyter, so restart the whole karnel it will do!!!
On Mac and Linux, the pip install pyemd works fine.
However, on Windows, you may experience an issue in installing this.
This error occurs due to
pyemd needing some C++ dependencies during build time.
This can be resolved by installing the Build Tools for Visual Studio 2019 as follows:
Download "Build Tools for Visual Studio" https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
Run the .exe file and select to install C++ build tools
Check that among the suggested packages to install it is also selected "Windows 10 SDK" (the newest version is fine) as this is the critical dependency
Once the installation has finished reopen your PowerShell/Command Prompt and retry to install the library with the original pip instruction
Check the documentation of wmdistance method
Warnings
--------
This method only works if pyemd <https://pypi.org/project/pyemd/>_ is installed.
If one of the documents have no words that exist in the vocab, `float('inf')` (i.e. infinity)
will be returned.
Raises
------
ImportError
If `pyemd <https://pypi.org/project/pyemd/>`_ isn't installed.
so before using the wmdistance install package pyemd
pip install pyemd
I want to use theano.tensor.nnet.relu, but I keep getting this error:
AttributeError: 'module' object has no attribute 'relu'
I have already updated theano via sudo pip install --upgrade theano command as described in theano's documentation, also i've tried sudo pip install --upgrade --no-deps theano. Neither worked, I still get the same error.
I was trying to do theano -v to confirm that I have installed the latest version but then I get the following error: -bash: theano: command not found
So my two questions here are:
How can I see theano's version?
Am I doing something wrong when updating theano? How can I solve the error first mentioned?
relu is available for theano >= 0.7.1. My guess is that pip linked to theano==0.7.
You can check theano version with pip freeze:
pip freeze | grep Theano
So you have to install latest theano with pointing pip to theano git repo :
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
Also note that relu is function and not module, so to access it you have to use one of imports below:
from theano.tensor.nnet import relu # access `relu` as is ..
import theano.tensor.nnet as theano_nnet #access `relu` as `theano_nnet.relu`
The theano.tensor.nnet module only supports relu in the most recent versions. In order to use it, you need to install the bleeding edge version from github or wait until the next release.
Alternatively, you can implement it like this:
def relu(x):
return T.maximum(x, 0.)
This may not be inplace but it gives you the result and the gradient.
to see theano version you can run the following code:
import theano
print theano.__version__
You should follow the instructions from here to get the bleeding edge version
Actually relu function is simple to code, you can create your own relu function, like eickenberg's answer, or like theano.tensor.nnet style:
def relu(x):
return 0.5 * (x + abs(x))
I running machine learning algo's with theano. I have been getting lot of warnings of DeprecationWarning. coming from numpy package. I want to disable this warnings pls suggest option.
warning nature:fromnumeric.py:932: DeprecationWarning: converting an array with ndim > 0 to an index will result in an error in the future
I tried following run configure added command line option -W ignore or -W ignore::DeprecationWarning but none of this is working
alternatively fixing the warning solution is fine for me. looks like its fixed in theano https://groups.google.com/forum/#!topic/theano-users/Hf7soRrnh8w but I dont know where to find this updated version of theano
I am using Anaconda distribution 2.0.1 windows 8.1 - 64 bit
thanks
See this link to update Theano to the development version. I should be fixed:
http://deeplearning.net/software/theano/install.html#bleeding-edge-install-instructions
In resume, run one of those 2 command:
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
or (if you want to install it for the current user only):
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git --user