-
Notifications
You must be signed in to change notification settings - Fork 795
nnx.tabulate breaks if nnx.Variable implements one of the value hooks #5005
Copy link
Copy link
Closed
Labels
Priority: P1 - soonResponse within 5 business days. Resolution within 30 days. (Assignee required)Response within 5 business days. Resolution within 30 days. (Assignee required)
Description
Hi,
(another visualization issue... 😅)
The following gives an error, which it should not I suppose:
from flax import nnx
class P(nnx.Variable):
def on_set_value(self, value):
return self.value + 1.0
class M(nnx.Module):
def __init__(self):
self.param = P(value=0.0)
def __call__(self, x):
return self.param * x
nnx.tabulate(M(), 2.0)
# ---------------------------------------------------------------------------
# RepresenterError Traceback (most recent call last)
# [/tmp/ipython-input-2062670779.py](https://qy6gqpckbx-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20251003-060040_RC00_814643377#) in <cell line: 0>()
# 12 return self.param * x
# 13
# ---> 14 nnx.tabulate(M(), 2.0)
#
# 12 frames
# [/usr/local/lib/python3.12/dist-packages/yaml/representer.py](https://qy6gqpckbx-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab_20251003-060040_RC00_814643377#) in represent_undefined(self, data)
# 229
# 230 def represent_undefined(self, data):
# --> 231 raise RepresenterError("cannot represent an object", data)
# 232
# 233 SafeRepresenter.add_representer(type(None),
#
# RepresenterError: ('cannot represent an object', <function P.on_set_value at 0x789fe827d3a0>)The same issue exists if on_get_value or on_create_value is implemented.
Best, Peter
System information:
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS Sequoia & Google Colab
- Flax, jax, jaxlib versions (obtain with
pip show flax jax jaxlib: 0.12.0 - Python version: 3.12
- GPU/TPU model and memory: -
- CUDA version (if applicable): -
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Priority: P1 - soonResponse within 5 business days. Resolution within 30 days. (Assignee required)Response within 5 business days. Resolution within 30 days. (Assignee required)