ImportError: cannot import name downsample
zyui opened this issue ยท 17 comments
`from sknn import ae
import numpy as np
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
x = np.asarray(range(0,16))
nn = ae.AutoEncoder(
layers=[
ae.Layer("Sigmoid", units=4),
ae.Layer("Sigmoid", units=8),
ae.Layer("Sigmoid", units=4)
],
learning_rate=0.02)
nn.fit(x)`
And then comes the arror_Traceback (most recent call last):
File "/Users/zzzyui/Desktop/CSE514A/hw4/ae1.py", line 17, in
learning_rate=0.02)
File "/Library/Python/2.7/site-packages/sknn/nn.py", line 513, in init
self._setup()
File "/Library/Python/2.7/site-packages/sknn/ae.py", line 100, in setup
backend.setup()
File "/Library/Python/2.7/site-packages/sknn/backend/init.py", line 24, in setup
from . import lasagne
File "/Library/Python/2.7/site-packages/sknn/backend/lasagne/init.py", line 5, in
from .mlp import MultiLayerPerceptronBackend
File "/Library/Python/2.7/site-packages/sknn/backend/lasagne/mlp.py", line 25, in
import lasagne.layers
File "/Library/Python/2.7/site-packages/lasagne/init.py", line 19, in
from . import layers
File "/Library/Python/2.7/site-packages/lasagne/layers/init.py", line 7, in
from .pool import *
File "/Library/Python/2.7/site-packages/lasagne/layers/pool.py", line 6, in
from theano.tensor.signal import downsample
ImportError: cannot import name downsample
Related to #234.
The only workaround I found for now is to force pip to downgrade Theano to 0.7.
This issue is happening because the latest released version of Lasagne (0.1) still uses downsample from Theano, but the latest released of Theano no longer supports downsample. @zyui @a01200356 If you prefer to use the newest version of Theano, you could alternatively upgrade Lasagne to the development version via pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip
(a la http://lasagne.readthedocs.io/en/latest/user/installation.html)
change from theano.tensor.signal.pool import max_pool_2d
to from theano.tensor.signal.pool import pool_2d
@dibidave Worked for me, thanks!
@dibidave It works for me! Thank you!
Worked for me too, thanks, @dibidave.
Sorry to reask this question again:
I installed the theano with version of 1.0.2, but I can not import the downsample module, I saw several posts for the same issue, and I tried to upgrade the version of Lasagne
pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip
, but it did not work for me.
I saw that the question was asked with theano for version of 0.8. So I wonder if anyone has the same issue for the lasted version of theano and has some workaround?
Thanks in advance
pip install -I theano==0.7
for anyone who needs it
@dibidave Thanks a lot!!!
You just need to install Theano & Lasagne again by following commands.
pip install --upgrade https://github.com/Theano/Theano/archive/master.zip
pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip