Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'theano' has no attribute 'ifelse'

I am installing anaconda environment with keras, and using theano backend. But I cannot get theano to work. here is what I have done and also errors noted afterwards.

Step 1: download the latest version of anaconda, then install in linux by ' bash Anaconda3-5.0.1-Linux-x86_64.sh'

Step 2: conda install -c conda-forge keras, which installs keras 2.0.9

This also installs theano 1.0.1, as shown below:

The following NEW packages will be INSTALLED:

    keras:       2.0.9-py36_0          conda-forge
    libgpuarray: 0.7.5-0               conda-forge
    mako:        1.0.7-py36_0          conda-forge
    pygpu:       0.7.5-py36_0          conda-forge
    theano:      1.0.1-py36_1          conda-forge

The following packages will be SUPERSEDED by a higher-priority channel:

    conda:       4.3.30-py36h5d9f9f4_0             --> 4.3.29-py36_0 conda-forge
    conda-env:   2.6.0-h36134e3_1                  --> 2.6.0-0       conda-forge

Next, testing theano:

python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
>>> theano.ifelse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'theano' has no attribute 'ifelse'

The error shown in the last line is preventing me using theano and keras properly. all my code that works on a different platform does not work, because they will generate an error like that.

I also tried to follow instructions on http://deeplearning.net/software/theano/install_ubuntu.html with a fresh anaconda installation to just install theano, without keras. But after installation, with the testing line above, I get the same error.

Any suggestion on how to fix this?

like image 610
Ziqi Avatar asked Nov 18 '22 23:11

Ziqi


1 Answers

It is not import by default.

Try to use

import theano.ifelse
like image 147
Euroka Avatar answered Dec 20 '22 17:12

Euroka