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.

Error in Deep_Kernel_Learning_DenseNet_CIFAR_Tutorial.ipynb

See original GitHub issue

In the tutorial example for Deep Kernel Learning on the CIFAR datasets there is an issue in the test() function. The following error is raised:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-30679d80b21c> in <module>
      3     with gpytorch.settings.use_toeplitz(False), gpytorch.settings.max_preconditioner_size(0):
      4         train(epoch)
----> 5         test()
      6     state_dict = model.state_dict()
      7     likelihood_state_dict = likelihood.state_dict()

<ipython-input-7-91f72c08681a> in test()
     35         with torch.no_grad():
     36             output = likelihood(model(data))
---> 37             pred = output.argmax()
     38             correct += pred.eq(target.view_as(pred)).cpu().sum()
     39     test_loss /= len(test_loader.dataset)

AttributeError: 'Categorical' object has no attribute 'argmax'

It appears that the output of likelihood() should be an instance of torch.Tensor, and not torch.distributions.categorical.Categorical. This is consistent with gpytorch.likelihoods.SoftmaxLikelihood. Should .argmax() be called on one of the attributes of output, or is there another recommended best practice to return the predictions?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
messiestcommented, Oct 16, 2018

@jacobrgardner I had been trying pred = output.probs.argmax(), but the dimension was wrong and would raise the following RuntimeError:

RuntimeError: shape '[]' is invalid for input of size 64

@gpleiss Excellent, works like a charm now. (Fixed locally).

0reactions
gpleisscommented, Oct 16, 2018

@messiest - just updated the example notebook. You might want to check out the new optimizer settings. In my latest experiments I’ve noticed that you want a much smaller learning rate on the kernel hyperparameters, but the GP’s variational parameters should have a pretty high learning rate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error loading IPython notebook - Stack Overflow
When I try to open the file (FunIT\ experiment.ipynb): ipython notebook FunIT\ experiment.ipynb. I get the following error message. Error loading notebook.
Read more >
File Load Error for getting_started.ipynb · Issue #11723 - GitHub
The path should be relative to the directory where JupyterLab was opened. For example if you are starting jupyter lab in /home/user you...
Read more >
Cannot export python notebook to ipython notebook or html ...
I edited a python notebook in databricks and I'd like to export it as ipython notebook or html file. However, I got the...
Read more >
Cannot upload "Linear Regression Practical Example (Part 2 ...
IPY", and when I click to upload it nothing happens. If I change the extension to ".ipynb" (as it should be), it appears...
Read more >
Error: Creating Notebook Failed. An error occurred while ...
ipynb. Error Message. Various ArcGIS modules can be used with the Jupyter Notebook application installed with ArcGIS Pro, and a folder location ...
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