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.

flax.errors.ScopeParamNotFoundError: No parameter named "kernel" exists in "/Conv_0".

See original GitHub issue

Model.apply({'params':params}, batch) in the loss function seems to throw the error above. I pretty much followed the examples in the docs line-by-line with no luck.

Here is a minimal example of the issue reproduced in google colab - https://colab.research.google.com/drive/12mRim_N4cWmv4nmeuknq8RT2VWUA5egB

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
andsteingcommented, May 4, 2021

you wrote

parameters = SimpleCNN6Layer(n=16).init({'params':jax.random.PRNGKey(0)}, jax.numpy.ones((16, 4000, 1)))
optimizer = optim.Adam(learning_rate=3e-4).create(parameters)

but you probably meant

variables = SimpleCNN6Layer(n=16).init({'params':jax.random.PRNGKey(0)}, jax.numpy.ones((16, 4000, 1)))
optimizer = optim.Adam(learning_rate=3e-4).create(variables['params'])
3reactions
marcvanzeecommented, May 4, 2021

You have to make sure you take the params of the variable dict returns by init. So when you create your optimizer you should do:

variables = SimpleCNN6Layer(n=16).init({'params':jax.random.PRNGKey(0)}, jax.numpy.ones((16, 4000, 1)))
optimizer = optim.Adam(learning_rate=3e-4).create(variables['params'])

The error message is not very clear, so thank you for bringing this up! 👍

We should consider improving the error message to something like “Maybe you passing in an incorrect variable dict”?

Read more comments on GitHub >

github_iconTop Results From Across the Web

flax.errors.ScopeParamNotFoundError: No parameter ... - GitHub
flax.errors.ScopeParamNotFoundError: No parameter named "kernel" exists in "/MLP_0/Dense_0" when attempting to use Jax2TF with a pre-trained JAX NeRF Model ...
Read more >
flax.errors
[docs]class ScopeParamNotFoundError(FlaxError): """This error is thrown when trying to access a parameter that does not exist. For instance, in the code ...
Read more >
Flax 2 ("Linen") - Colaboratory - Google Colab
Let's instantiate a Dense layer. Modules are actually objects in this API, so we provide contructor arguments when initializing the Module. In this...
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