wandb / wandb

🔥 A tool for visualizing and tracking your machine learning experiments. This repo contains the CLI and Python API.

Home Page:https://wandb.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[CLI]: "property 'model' of 'WandbCallback' object has no setter"

stellarpower opened this issue · comments

Describe the bug

I believe something has changed in Keras 3 (at least in the master branch) relating to how callbacks are handled - the Callbacks class now has a model member built in; this is a python attribute, and so means that trying to assign to it in the constructor of a callback raises an exception that the model is read-only and so has no assignment function.

I actually hit this in my own callbvack earlier today, and I don't know if this is potentially a bug in Keras or it's something that will be here to stay in stable releases, but I see it in
keras-nightly 3.3.3.dev2024050603, and assuming the latter, lines like this one will be a problem - by the time the parent constructor has run, self.model is already a member of the class, and is actually wrapping the hidden member, hence the issue with trying to assign to it.

The quick and dirty workaround I took in my own code was simply to give the variable a different name (e.g. Model - _model is already in use, I believe).

Cheers

Additional Files

No response

Environment

WandB version: This affects master

OS:

Python version:

Versions of relevant libraries: Keras 3.3.3 nightly with TF (although it ought to be backend-agnostic)

Additional Context

No response

hey @stellarpower - I was able to reproduce this with the general Callback class as well. is this occurring when you try accessing WandbMetricsLogger ? I'll be sure to flag this behavior with our integrations team

Also, please note that WandbCallback is a legacy callback so we recommend using the three new callback we added in 0.13.4 (docs here 20)

Hi, thakns.

I don't think so, as I don't think I hit this problem with the other callback; I use the legacy callback because I think there isn't a new one for logging gradients, and that's one of the main reasons for using W&B, as this isn't available in Tensorboard anymore. So I generally run my models with both.

I'll let you know if I see evidence ot hte contrary though.