question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SVI notebook errors in Python 3.5

See original GitHub issue

Hi! I’m trying to run the SVI notebook (http://nbviewer.jupyter.org/github/SheffieldML/notebook/blob/master/GPy/SVI.ipynb) on Python 3.5 using the devel branch of GPy. I get the following error at In [4]:

Z = np.random.rand(20,1)

batchsize = 10
m = GPy.core.SVGP(X, Y, Z, GPy.kern.RBF(1) + GPy.kern.White(1), GPy.likelihoods.Gaussian(), batchsize=batchsize)
m.kern.white.variance = 1e-5
m.kern.white.fix()
---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-4-382f732b700d> in <module>()
      2 
      3 batchsize = 10
----> 4 m = GPy.core.SVGP(X, Y, Z, GPy.kern.RBF(1) + GPy.kern.White(1), GPy.likelihoods.Gaussian(), batchsize=batchsize)
      5 m.kern.white.variance = 1e-5
      6 m.kern.white.fix()


/.../lib/python3.5/site-packages/paramz/parameterized.py in __call__(self, *args, **kw)
     46         self._in_init_ = True
     47         #import ipdb;ipdb.set_trace()
---> 48         self = super(ParametersChangedMeta, self).__call__(*args, **kw)
     49         #logger.debug("finished init")
     50         self._in_init_ = False


/.../lib/python3.5/site-packages/GPy/core/svgp.py in __init__(self, X, Y, Z, kernel, likelihood, mean_function, name, Y_metadata, batchsize, num_latent_functions)
     34             #Make a climin slicer to make drawing minibatches much quicker
     35             self.slicer = climin.util.draw_mini_slices(self.X_all.shape[0], self.batchsize)
---> 36             X_batch, Y_batch = self.new_batch()
     37 
     38         #create the SVI inference method


/.../lib/python3.5/site-packages/GPy/core/svgp.py in new_batch(self)
     90         Return a new batch of X and Y by taking a chunk of data from the complete X and Y
     91         """
---> 92         i = next(self.slicer)
     93         return self.X_all[i], self.Y_all[i]
     94 


/.../lib/python3.5/site-packages/climin/util.py in draw_mini_slices(n_samples, batch_size, with_replacement)
     90     else:
     91         while True:
---> 92             random.shuffle(idxs)
     93             for i in idxs:
     94                 yield slices[i]


/usr/lib/python3.5/random.py in shuffle(self, x, random)
    270                 # pick an element in x[:i+1] with which to exchange x[i]
    271                 j = randbelow(i+1)
--> 272                 x[i], x[j] = x[j], x[i]
    273         else:
    274             _int = int


TypeError: 'range' object does not support item assignment

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
wilocwcommented, Sep 19, 2018

This seems to work/not work depending on the version of climin. The PyPI version of climin is different to the Github version. Installing via pip install climin will install climin 0.1a1 from PyPI, but following the instructions on the readthedocs, as follows, will install climin pre-0.1, which should work with Python 3.5+:

$ git clone https://github.com/BRML/climin.git /path/to/climin
$ cd /path/to/climin
$ pip install -e .
0reactions
mohammadalimehdizadehcommented, May 2, 2020

i have the same problem with google colab python version3.6 and @wilocw solution work well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception: The non-notebook version of vpython requires ...
Once i tried importing the library, this error came up: Exception: The non-notebook version of vpython requires Python 3.5 or later. vpython ...
Read more >
8. Errors and Exceptions — Python 3.11.1 documentation
Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are still learning Python:....
Read more >
Running Jupyter notebook --- Existing python 3.5 interferes
I'm trying to run a MAF tutorial in a jupyter notebook and I am getting this error when I try to start jupyter:...
Read more >
Cumulus Linux | Cumulus Linux 4.3 - NVIDIA Documentation Center
If your host (laptop or server) is IPv6-enabled, make sure it is running a web ... user@host:~$ python3 -c "import crypt; print(crypt.crypt('MyP4$$word' ...
Read more >
computation of circular area and spherical volume invariants via ...
that u is smooth but continue to impose the boundary condition in (3.5). ... in that it leads to a simple form for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found