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.

Question - Defining a tuple as a parameter in a config file

See original GitHub issue

Hi!

I’m using Hydra with PyTorch Lightning to configure my model. One of the hyperparameters of my data module is a variable that corresponds to a tuple of 3 floats.

In the datamodule.yaml config file, I wrote:

_target_: src.datamodules.keri_datamodule.KeriDataModule
pix_dim: (0.5, 0.5, 0.781)

However, I get the following error: ValueError: Error instantiating 'src.datamodules.keri_datamodule.KeriDataModule': could not convert string to float: '(0.5, 0.5, 0.781)'

What syntax should I use to explain to Hydra that it’s a tuple / sequence and not a string or a list to sweep through?

Thanks for your help 😃

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
Jasha10commented, May 29, 2021

Currently tuples do not have full support (see https://github.com/omry/omegaconf/issues/392). Is it possible to use a list, i.e. pix_dim: [0.5, 0.5, 0.781]?

2reactions
aksg87commented, Jun 10, 2021

Thank you @Jasha10 🙂 Really helpful examples!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Pass a Tuple as an Argument to a Function?
Tuples can be defined using any variable name and then assigning different values to the tuple inside the round brackets. The tuple is...
Read more >
tuples as function arguments - python - Stack Overflow
When you call a function, you're not providing a tuple. You're providing arguments. A tuple can be an argument, but only one -...
Read more >
How correctly pass to a command a tuple of parameters ...
Your problem is that you are passing the key values incorrectly. At first the option is trim= 0.5cm 0.5cm 0.5cm 0.5cm and not...
Read more >
Using a tuple to Input the parameters of a function - Python
MY QUESTION: Why does a function not accept a tuple as an input for it's parameters? As I understand it, a tuple is...
Read more >
Kinds of types - mypy 0.991 documentation
tuple [...] is valid as a base class in Python 3.6 and later, and always in stub files. In earlier Python versions you...
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