pythongoogle-colaboratorytheano

Unable to import local_bitwidth from Theano on google colab while importing shared_randomstreams.RandomStreams


I am having an issue to import 'local_bitwidth' from 'theano.configdefaults'. And the following message was displayed:

ImportError                               Traceback (most recent call last)
<ipython-input-80-1e0aa55408e4> in <module>()
     39 from theano.tensor.nnet import conv
     40 from theano.tensor.nnet import softmax
---> 41 from theano.tensor import shared_randomstreams
     42 from theano.tensor.signal.pool import pool_2d
     43 

7 frames
/usr/local/lib/python3.7/dist-packages/theano/gof/cmodule.py in <module>()
     35 # we will abuse the lockfile mechanism when reading and writing the registry
     36 from theano.gof import compilelock
---> 37 from theano.configdefaults import gcc_version_str, local_bitwidth
     38 
     39 importlib = None

ImportError: cannot import name 'local_bitwidth' from 'theano.configdefaults' (/usr/local/lib/python3.7/dist-packages/theano/configdefaults.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

I received this error while I was trying to run this code first:

from theano import function
srng = RandomStreams(seed=234)
rv_u = srng.uniform((2,2))
rv_n = srng.normal((2,2))
f = function([], rv_u)
g = function([], rv_n, no_default_updates=True)    #Not updating rv_n.rng
nearly_zeros = function([], rv_u + rv_u - 2 * rv_u)

and after when I ran the convolutional neural network example from Michael Nielsen's book where there is a line that calls the RandomStreams method. Both of them I ran on google collab, is there anyway to handle it on colab?


Solution

  • I have faced here the same issue yesterday, you need to install the 1.0.5 version of Theano maybe you are using a different version than this one.

    In Google colab: !pip3 uninstall theano

    And: !pip3 install theano==1.0.5