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.

Passing a numpy array with a single value to wandb.config will convert it to a string

See original GitHub issue
  • Weights and Biases version: 0.9.4
  • Python version: 3.6.9
  • Operating System: Linux

Description

I was trying to pass a numpy array with a single value to wandb.config, and was surprised that it’s automatically converted to a str. However, I am not quite sure whether it’s a bug or not, feel free to close this if it’s intentional.

What I Did

wandb.config.testing = np.array([2. ], dtype=np.float32)
print(wandb.config.testing, type(wandb.config.testing))

will output:

2.0 <class 'str'>

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nate-wandbcommented, Jan 26, 2022

Hi @Al-Murphy, That’s really interesting. I was able to get the same results as you and it was independent of Python version. I’ll let engineering know the bug is related to calling wandb.init()

Thank you for helping trace it to back to the source.

As a work around, NumPy can parse a list of strings to a numpy array of floats so I would recommend calling np.array() if you use the config variable later in your code until we can address the bug.

Thank you again for bringing this to our attention, Nate

1reaction
Al-Murphycommented, Jan 26, 2022

Hey @nate-wandb,

So I’ve noticed some very strange behaviour - on a new, empty notebook the array isn’t converted to a str:

[2.] <class 'numpy.ndarray'>
0.12.9
3.9.7 (default, Sep 16 2021, 13:09:58) 
[GCC 7.5.0]

And also on my current notebook, if I restart the kernel and run just the lines you sent me, again there is no issue. Only when I run my actual code first does an issue appear that it’s converted to a str. I then found what’s causing the issue through process of elimination and it turns out its:

wandb.init(
    name='test1',
    entity="al-murphy",
    project="test",
)

Once I run this and the commands you posted (on either notebook), I get the following:

2.0 <class 'str'>
0.12.9
3.9.7 (default, Sep 16 2021, 13:09:58) 
[GCC 7.5.0]

Are you aware of this causing an issue? Just to note when I run the wandb.init I do get the following warning:

Failed to detect the name of this notebook, you can set it manually with the WANDB_NOTEBOOK_NAME environment variable to enable code saving.
wandb: Currently logged in as: al-murphy (use `wandb login --relogin` to force relogin)
/rds/general/user/aemurphy/home/anaconda3/envs/py_analysis/lib/python3.9/site-packages/IPython/html.py:12: ShimWarning: The `IPython.html` package has been deprecated since IPython 4.0. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  warn("The `IPython.html` package has been deprecated since IPython 4.0. "
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure Experiments with wandb.config - Documentation
You can pass in the arguments returned by argparse . This is convenient for quickly testing different hyperparameter values from the command line....
Read more >
Log Data with wandb.log - Documentation - Weights & Biases
log() with a different value for step than the previous one, W&B will write all the collected keys and values to the history,...
Read more >
wandb.data_types.Video - Documentation
(numpy array, string, io) Video can be initialized with a path to a file or an io object. The format must be "gif",...
Read more >
wandb.data_types.Object3D - Documentation
data_or_path. (numpy array, string, io) Object3D can be initialized from a file or a numpy array. You can pass a path to a...
Read more >
Log Media & Objects - Documentation - Weights & Biases
Images can be logged directly from numpy arrays, as PIL images, ... a dictionary with the following keys and values to the masks...
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