Theano: UserWarning: downsample module has been moved

Created on 5 Apr 2016  Â·  17Comments  Â·  Source: Theano/Theano

Hi,

I just upgraded from Theano 0.7 to 0.8, When I use:

from theano.tensor.signal import downsample

I get:

/usr/local/lib/python3.4/dist-packages/theano/tensor/signal/downsample.py:6: UserWarning: downsample module has been moved to the theano.tensor.signal.pool module. "downsample module has been moved to the theano.tensor.signal.pool module.")

But if I use:

from theano.tensor.signal.pool import downsample

I get:

ImportError: cannot import name 'downsample'

How to fix this or is this a bug?

Thanks,

Jos

Most helpful comment

Same issue [theano v.0.9.0dev1.dev-2...]; changed

from theano.tensor.signal import downsample
...
pooled_out = downsample.max_pool_2d( ... )

to

from theano.tensor.signal import pool
...
pooled_out = pool.pool_2d( ... )

Works!

All 17 comments

Le 5 avr. 2016 13:41, "Jos van Roosmalen" [email protected] a
écrit :

Hi,

I just upgraded from Theano 0.7 to 0.8, When I use:

from theano.tensor.signal import downsample

I get:

/usr/local/lib/python3.4/dist-packages/theano/tensor/signal/downsample.py:6:
UserWarning: downsample module has been moved to the
theano.tensor.signal.pool module. "downsample module has been moved to the
theano.tensor.signal.pool module.")

But if I use:

from theano.tensor.signal.pool import downsample

Use

From Theano.tensor.signal import pool

And use the pool_2d() function.

Fred

I get:

ImportError: cannot import name 'downsample'

How to fix this or is this a bug?

Thanks,

Jos

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

Same issue [theano v.0.9.0dev1.dev-2...]; changed

from theano.tensor.signal import downsample
...
pooled_out = downsample.max_pool_2d( ... )

to

from theano.tensor.signal import pool
...
pooled_out = pool.pool_2d( ... )

Works!

After this change, you should delete your Theano cache as it can still load
the old module. After that, you should not get errors anymore.

On Thu, Aug 11, 2016 at 10:27 PM, Victoria Stuart [email protected]
wrote:

Same issue [theano v.0.9.0dev1.dev-2...]; changed

from theano.tensor.signal import downsample
...
pooled_out = downsample.max_pool_2d( ... )

to

from theano.tensor.signal import pool
...
pooled_out = pool.pool_2d( ... )

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/Theano/Theano/issues/4337#issuecomment-239347032, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AALC-2Vo0A3ttPvi3zcSjlsIUurEmZGAks5qe9oJgaJpZM4IAd1e
.

Sorry, I know this thread is closed, but for anyone else searching/reading (as I did) ...

Delete Theano cache [ https://github.com/Theano/Theano/issues/3818 ]:

You can delete your theano cache with the command

theano-cache purge

If that does not work do this in python to know the path of the cache and delete this directory:

import theano
print theano.config.compiledir

What file(s) do I make the suggested edit?

from theano.tensor.signal import downsample
...
pooled_out = downsample.max_pool_2d( ... )

to

from theano.tensor.signal import pool
...
pooled_out = pool.pool_2d( ... )

I modified the base.py file using the first line: from theano.tensor.signal import pool but I'm unable to find the pooled_out line.

Ahh, sorry: I should have mentioned the file! I believe that the file in question (I had to grep to find it) is:

[victoria@victoria theano]$ rg . -e "pooled_out"    ## rg: "ripgrep"
    convolutional_mlp.py
    163: #pooled_out = downsample.max_pool_2d(
    164: pooled_out = pool.pool_2d(
    174: self.output = T.tanh(pooled_out + self.b.dimshuffle('x', 0, 'x', 'x'))

i.e.

/home/victoria/projects/theano/convolutional_mlp.py

which is a file from the Theano tutorial,

http://deeplearning.net/tutorial/lenet.html

with the code linked near the top of that tutorial:

http://deeplearning.net/tutorial/code/convolutional_mlp.py

In my downloaded copy of that script (Aug 2016) I have the following edit:

...
    # downsample each feature map individually, using maxpooling
    #pooled_out = downsample.max_pool_2d(
    pooled_out = pool.pool_2d(
        input=conv_out,
        ds=poolsize,
        ignore_border=True
    )
...

It appears that the online version has been updated, perhaps in response to this Issue/thread, as "downsample.max_pool_2d" no onger appears in that file.

I hope that helps! :-)


My configuration:

Arch Linux x86_64; Intel Core i7-4790 CPU; ... Theano in Python 2.7 virtual environment ...

[victoria@victoria ~]$ thee

[Theano in Anaconda Python 2.7 venv (source activate theano-env)]

(theano-env) [victoria@victoria ~]$ which python

/home/victoria/anaconda3/envs/theano-env/bin/python

(theano-env) [victoria@victoria ~]$ python --version

Python 2.7.12 :: Anaconda custom (64-bit)

(theano-env) [victoria@victoria ~]$ P

[P: python]
Python 2.7.12 |Anaconda custom (64-bit)| (default, Jul  2 2016, 17:42:40) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

>>> import theano

>>> theano .__version__
'0.9.0dev1.dev-2a9da88c31f902a39b7ab280ae2a10b46887ff58'

>>> [Ctrl-D]

(theano-env) [victoria@victoria ~]$

Thank you Victoria.

@victoriastuart Hi Victoria, I changed my code according to what you said. But it give me an error as below. I was previously using one version of theano 0.9.0. It worked well. But after I update, it doesn't work. Maybe, should reinstall theano 0.9.0 rc1?

runfile('/space/xzhang/git_cnn_conversion/MyLasagneCode_CIFAR10/test_convnet_new.py', wdir='/space/xzhang/git_cnn_conversion/MyLasagneCode_CIFAR10')
Reloaded modules: cutils_ext, tmp7SSxi_, lazylinker_ext.lazylinker_ext, data_utils, tmp7SSxi_.11617ef9bd367a3818a3537ffe37d382, lazylinker_ext, cutils_ext.cutils_ext
Compiling...
theano_layers.py:257: UserWarning: DEPRECATION: the 'ds' parameter is not going to exist anymore as it is going to be replaced by the parameter 'ws'.
impulse = downsample.max_pool_2d(inp, ds=self.poolsize, st=self.stride, ignore_border=self.ignore_border, mode='average_inc_pad')
Traceback (most recent call last):

File "", line 1, in
runfile('/space/xzhang/git_cnn_conversion/MyLasagneCode_CIFAR10/test_convnet_new.py', wdir='/space/xzhang/git_cnn_conversion/MyLasagneCode_CIFAR10')

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile
execfile(filename, namespace)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 94, in execfile
builtins.execfile(filename, *where)

File "/space/xzhang/git_cnn_conversion/MyLasagneCode_CIFAR10/test_convnet_new.py", line 136, in
main(**kargs)

File "/space/xzhang/git_cnn_conversion/MyLasagneCode_CIFAR10/test_convnet_new.py", line 96, in main
get_output = theano.function([input_var, input_time], [new_mem, output_time, Ntransmittedspikes, conv1_spikes, conv2_spikes, conv3_spikes], updates=updates)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/compile/function.py", line 326, in function
output_keys=output_keys)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 486, in pfunc
output_keys=output_keys)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/compile/function_module.py", line 1808, in orig_function
output_keys=output_keys)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/compile/function_module.py", line 1478, in __init__
optimizer_profile = optimizer(fgraph)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gof/opt.py", line 98, in __call__
return self.optimize(fgraph)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gof/opt.py", line 87, in optimize
ret = self.apply(fgraph, args, *kwargs)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gof/opt.py", line 241, in apply
sub_prof = optimizer.optimize(fgraph)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gof/opt.py", line 87, in optimize
ret = self.apply(fgraph, args, *kwargs)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gof/opt.py", line 241, in apply
sub_prof = optimizer.optimize(fgraph)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gof/opt.py", line 87, in optimize
ret = self.apply(fgraph, args, *kwargs)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gpuarray/opt.py", line 382, in apply
node.outputs)

File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gpuarray/opt.py", line 1347, in local_gpua_error_convop
"""

AssertionError:
ConvOp does not work with the gpuarray backend.

Use the new convolution interface to have GPU convolution working:
theano.tensor.nnet.conv2d()

You need to call:

theano.tensor.nnet.conv2d()

instead of theano.tensor.nnet.conv.conv2d()

On Wed, Apr 5, 2017 at 11:18 PM Victoria Stuart notifications@github.com
wrote:

Ahh, sorry: I should have mentioned the file! I believe that the file in
question (I had to grep to find it) is:

[victoria@victoria theano]$ rg . -e "pooled_out" ## rg: "ripgrep"
convolutional_mlp.py
163: #pooled_out = downsample.max_pool_2d(
164: pooled_out = pool.pool_2d(
174: self.output = T.tanh(pooled_out + self.b.dimshuffle('x', 0, 'x', 'x'))

i.e.

/home/victoria/projects/theano/convolutional_mlp.py

which is a file from the Theano tutorial,

http://deeplearning.net/tutorial/lenet.html

with the code linked near the top of that tutorial:

http://deeplearning.net/tutorial/code/convolutional_mlp.py

In my downloaded copy of that script (Aug 2016) I have the following edit:

...
# downsample each feature map individually, using maxpooling
#pooled_out = downsample.max_pool_2d(
pooled_out = pool.pool_2d(
input=conv_out,
ds=poolsize,
ignore_border=True
)
...

It appears that the online version has been updated, perhaps in response
to this Issue/thread, as "downsample.max_pool_2d" no onger appears in that
file.

I hope that helps! :-)

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/Theano/Theano/issues/4337#issuecomment-292057945, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AALC-14NE-pnASisKa-00ZpKa1xUD6vlks5rtFmUgaJpZM4IAd1e
.

@nouiz I see. Thank you. I fixed that problem. But it comes up with a new error saying:

ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 175, in
use(config.device)
File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 162, in use
init_dev(device, preallocate=preallocate)
File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 73, in init_dev
context.cudnn_handle = dnn._make_handle(context)
File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 80, in _make_handle
cudnn = _dnn_lib()
File "/space/xzhang/anaconda2/lib/python2.7/site-packages/theano/gpuarray/dnn.py", line 67, in _dnn_lib
raise RuntimeError('Could not find cudnn library (looked for v5[.1])')
RuntimeError: Could not find cudnn library (looked for v5[.1])
Using Theano backend.
Compiling...
/space/xzhang/git_cnn_conversion/MyLasagneCode_CIFAR10/theano_layers.py:257: UserWarning: DEPRECATION: the 'ds' parameter is not going to exist anymore as it is going to be replaced by the parameter 'ws'.
impulse = pool.pool_2d(inp, ds=self.poolsize, st=self.stride, ignore_border=self.ignore_border, mode='average_inc_pad')

I get this problem when using lasagne:

Traceback (most recent call last):
  File "train.py", line 11, in <module>
    import lasagne
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/__init__.py", line 19, in <module>
    from . import layers
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/layers/__init__.py", line 7, in <module>
    from .pool import *
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/layers/pool.py", line 6, in <module>
    from theano.tensor.signal import downsample
ImportError: cannot import name downsample
entailment
Traceback (most recent call last):
  File "train.py", line 11, in <module>
    import lasagne
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/__init__.py", line 19, in <module>
    from . import layers
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/layers/__init__.py", line 7, in <module>
    from .pool import *
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/layers/pool.py", line 6, in <module>
    from theano.tensor.signal import downsample
ImportError: cannot import name downsample
sentiment
Traceback (most recent call last):
  File "train.py", line 11, in <module>
    import lasagne
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/__init__.py", line 19, in <module>
    from . import layers
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/layers/__init__.py", line 7, in <module>
    from .pool import *
  File "/Users/loretoparisi/Documents/MyProjects/SIF/.env/lib/python2.7/site-packages/lasagne/layers/pool.py", line 6, in <module>
    from theano.tensor.signal import downsample
ImportError: cannot import name downsample

Using:

(.env) [loretoparisi@:mbploreto SIF]$ python -c "import theano; print theano .__version__"
0.9.0

So I have solved in this way:

(.env) [loretoparisi@:mbploreto SIF]$ pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip
Collecting https://github.com/Lasagne/Lasagne/archive/master.zip
  Downloading https://github.com/Lasagne/Lasagne/archive/master.zip
     | 235kB 905kB/s
Requirement already up-to-date: numpy in ./.env/lib/python2.7/site-packages (from Lasagne==0.2.dev1)
Installing collected packages: Lasagne
  Found existing installation: Lasagne 0.1
    Uninstalling Lasagne-0.1:
      Successfully uninstalled Lasagne-0.1
  Running setup.py install for Lasagne ... done
Successfully installed Lasagne-0.2.dev1
(.env) [loretoparisi@:mbploreto SIF]$ python -c "import lasagne; print lasagne .__version__"
0.2.dev1

I have reported it here.

From Theano.tensor.signal import pool

And use the pool_2d() function.

worked for me!

As on the report, he was using a too old Lasagne for the Theano version he
was using.

On Fri, Aug 18, 2017 at 9:56 PM Philippe Rémy notifications@github.com
wrote:

From Theano.tensor.signal import pool

And use the pool_2d() function.

worked for me!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Theano/Theano/issues/4337#issuecomment-323492870, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AALC-_LSUo7YlGX3vmYLBTPmzP4hXotMks5sZkDkgaJpZM4IAd1e
.

@nouiz yes same thing happened to me. It was due to Lasagne.

If i do

import lasagne

I get

from theano.tensor.signal import downsample
ImportError: cannot import name 'downsample'

is it because of my python version ? (3.5)

This is because your Theano version is too recent compared to your Lasagne version.

Can you update Lasagne to the dev version on github? The one obtained with pip install lasagne is old.

Was this page helpful?
0 / 5 - 0 ratings