Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Theano - Keras - No Module named `pool`

I have installed a bleeding edge theano, and the following packages in following order:

gfortran:

sudo apt-get install gfortran 

OpenBLAS:

git clone https://github.com/xianyi/OpenBLAS  
cd OpenBLAS  
make FC=gfortran  
sudo make PREFIX=/usr/local install 

Anaconda, first downloaded Anaconda3-2.4.1-Linux-x86_64.sh, and then:

bash Anaconda3-2.4.1-Linux-x86_64.sh  

Then, pydot (after updating):

conda update conda  
conda update anaconda  
conda install pydot 

Them I cloned and installed Theano:

git clone git://github.com/Theano/Theano.git
python setup.py develop

I moved from windows to linux and got very happy that theano is installed.

I run a small script, to verify it is indeed working correctly.

from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy as np
import time

vlen = 10*30*768 # assuming 30 cores and 768 threads per core
iters = 1000

rng = np.random.RandomState(22)
x = shared(np.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))

print (f.maker.fgraph.toposort()  )
t0 = time.time()
for i in range (iters):
    r = f()
t1 = time.time()
print("Looping " + str(iters) + " times took " + str(t1-t0) + "seconds")
print("Result is " + str(r))
if np.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print ("Used the CPU")
else:
    print (" Used the GPU")

So, it is working, may be a trivial example to prove a point.

After that, comes keras

git clone https://github.com/fchollet/keras.git
python setup.py install

Then I change to examples directory of keras, and simply type in

python mnist_mlp.py

I get the following error:

Traceback (most recent call last):
  File "mnist_mlp.py", line 13, in <module>
    from keras.models import Sequential
  File "/home/user/anaconda3/lib/python3.5/site-packages/Keras-0.3.1-py3.5.egg/keras/models.py", line 15, in <module>
  File "/home/user/anaconda3/lib/python3.5/site-packages/Keras-0.3.1-py3.5.egg/keras/backend/__init__.py", line 46, in <module>
  File "/home/user/anaconda3/lib/python3.5/site-packages/Keras-0.3.1-py3.5.egg/keras/backend/theano_backend.py", line 4, in <module>
  File "/home/user/anaconda3/lib/python3.5/site-packages/Theano-0.8.0.dev0-py3.5.egg/theano/tensor/signal/downsample.py", line 2, in <module>
    import pool
ImportError: No module named 'pool'

Now, what the hell....Am I missing some package?

I think this is not issue of keras but rather problem with theano.

I went ahead and tried a dirty trick, pip install pool, and then rerun the above example, but I get the error:

module 'pool' has no attribute 'max_pool2D'

I can provide a stack trace as well, if needed.

I have struggled a lot in getting theano going, eagerly want to get started... before entire energy drains in the installations,

like image 560
Adorn Avatar asked Oct 30 '22 11:10

Adorn


1 Answers

It seems it cannot compile the file theano/tensor/signal/pool.py there is a issue and fix on github

like image 133
Fabio Fumarola Avatar answered Nov 15 '22 05:11

Fabio Fumarola