tensorflow / gnn

TensorFlow GNN is a library to build Graph Neural Networks on the TensorFlow platform.
Apache License 2.0
1.36k stars 179 forks source link

calling layer 'graph_update' (type GraphUpdate) - __dict__ descriptor does not support '_DictWrapper' objects #810

Closed genman closed 3 months ago

genman commented 5 months ago

Env:

MacOS 14.4.1
Python 3.12.2
tensorboard               2.16.2
tensorboard-data-server   0.7.2
tensorflow                2.16.1
tensorflow-gnn            1.0.3
tensorflow-macos          2.16.1

Installation was done using venv/pip.

Running the simple tfgnn_intro_mutag_example.py leads to this error during model.fit()

    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/training.py", line 1398, in train_function  *
        return step_function(self, iterator)
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/training.py", line 1370, in run_step  *
        outputs = model.train_step(data)
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/training.py", line 1147, in train_step  *
        y_pred = self(x, training=True)
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/training.py", line 565, in error_handler  *
        del filtered_tb
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/training.py", line 588, in __call__  *
        return super().__call__(*args, **kwargs)
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/training.py", line 565, in error_handler  *
        del filtered_tb
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/base_layer.py", line 1136, in __call__  *
        outputs = call_fn(inputs, *args, **kwargs)
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/functional.py", line 514, in call  *
        return self._run_internal_graph(inputs, training=training, mask=mask)
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/functional.py", line 671, in _run_internal_graph  *
        outputs = node.layer(*args, **kwargs)
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/training.py", line 560, in error_handler  *
        filtered_tb = _process_traceback_frames(e.__traceback__)
    File "venv/lib/python3.12/site-packages/tf_keras/src/engine/base_layer.py", line 1136, in __call__  *
        outputs = call_fn(inputs, *args, **kwargs)
    File "/var/folders/d6/pvpz4yg905lb07k_xncm4z0c0000gp/T/__autograph_generated_filek6d99w7b.py", line 162, in error_handler  **
        raise ag__.converted_call(ag__.ld(new_e).with_traceback, (ag__.ld(e).__traceback__,), None, fscope_1) from None
    File "/var/folders/d6/pvpz4yg905lb07k_xncm4z0c0000gp/T/__autograph_generated_filek6d99w7b.py", line 34, in error_handler
        retval__1 = ag__.converted_call(ag__.ld(fn), tuple(ag__.ld(args)), dict(**ag__.ld(kwargs)), fscope_1)
    File "/var/folders/d6/pvpz4yg905lb07k_xncm4z0c0000gp/T/__autograph_generated_filela5gng5y.py", line 63, in tf__call  **
        ag__.if_stmt(ag__.ld(self)._edge_set_updates, if_body_1, else_body_1, get_state_2, set_state_2, ('graph',), 1)
    File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/typing.py", line 1871, in __instancecheck__
        val = getattr_static(instance, attr)
    File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1839, in getattr_static
        instance_result = _check_instance(obj, attr)
    File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1793, in _check_instance
        instance_dict = object.__getattribute__(obj, "__dict__")

    TypeError: Exception encountered when calling layer 'graph_update' (type GraphUpdate).

    this __dict__ descriptor does not support '_DictWrapper' objects

    Call arguments received by layer 'graph_update' (type GraphUpdate):
      • graph=GraphTensor(
      context=Context(features={}, sizes=Tensor("model/map_features/ones_like:0", shape=(None,), dtype=int32), shape=(), indices_dtype=tf.int32),
      node_set_names=['atoms'],
      edge_set_names=['bonds'])
genman commented 4 months ago

tfgnn_intro_mutag_example.py.txt

I'm facing the same issue in some GNN code that worked on an older release–from about May 2023. (I don't know the precise version.)

arnoegw commented 4 months ago

Hi @genman , thank you for your report!

Please let me ask: Does the problem go away if you replace the packages tensorflow and tf-keras by the most recent versions 2.17.0rc* while keeping Python at 3.12? I think there might be an issue with the combination of older TF/Keras and Python 3.12.

arnoegw commented 3 months ago

there might be an issue with the combination of older TF/Keras and Python 3.12.

In the absence of reports to the contrary, I think that's the resolution.