Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: _lookup_dependency() takes 2 positional arguments but 3 were given #61265

Closed
ngbusca opened this issue Jul 13, 2023 · 3 comments
Closed
Assignees
Labels
comp:apis Highlevel API related issues comp:model Model related issues stat:awaiting response Status - Awaiting response from author type:bug Bug

Comments

@ngbusca
Copy link

ngbusca commented Jul 13, 2023

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.14.0-dev20230712

Custom code

Yes

OS platform and distribution

Linux moe 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 GNU/Linux

Mobile device

No response

Python version

3.9

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

Can't load saved model

Standalone code to reproduce the issue

Saved models can't be loaded:


model = tf.keras.models.Sequential([tf.keras.layers.Input((256,256,3)), tf.keras.layers.Dense(1)])
model.save("../models/test")
model = tf.keras.models.load_model("../models/test/")

same thing with more complex models

model = tf.keras.applications.efficientnet.EfficientNetB0()
model.save("../models/test")
model = tf.keras.models.load_model("../models/test/")


### Relevant log output

```shell
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[11], line 1
----> 1 model = tf.keras.models.load_model("../models/test/")

File ~/.local/lib/python3.9/site-packages/keras/src/saving/saving_api.py:262, in load_model(filepath, custom_objects, compile, safe_mode, **kwargs)
    254     return saving_lib.load_model(
    255         filepath,
    256         custom_objects=custom_objects,
    257         compile=compile,
    258         safe_mode=safe_mode,
    259     )
    261 # Legacy case.
--> 262 return legacy_sm_saving_lib.load_model(
    263     filepath, custom_objects=custom_objects, compile=compile, **kwargs
    264 )

File ~/.local/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py:70, in filter_traceback.<locals>.error_handler(*args, **kwargs)
     67     filtered_tb = _process_traceback_frames(e.__traceback__)
     68     # To get the full stack trace, call:
     69     # `tf.debugging.disable_traceback_filtering()`
---> 70     raise e.with_traceback(filtered_tb) from None
     71 finally:
     72     del filtered_tb

File ~/.local/lib/python3.9/site-packages/tensorflow/python/checkpoint/restore.py:606, in _queue_children_for_restoration(checkpoint_position, visit_queue)
    604   continue
    605 child_position = checkpoint_position.create_child_position(child.node_id)
--> 606 local_object = trackable._lookup_dependency(child.local_name,
    607                                             trackable_children)
    608 child_proto = child_position.object_proto
    609 if local_object is None:
    610   # We don't yet have a dependency registered with this name. Save it
    611   # in case we do.

TypeError: _lookup_dependency() takes 2 positional arguments but 3 were given
@google-ml-butler google-ml-butler bot added the type:bug Bug label Jul 13, 2023
@SuryanarayanaY SuryanarayanaY added comp:model Model related issues comp:apis Highlevel API related issues labels Jul 13, 2023
@SuryanarayanaY
Copy link
Collaborator

Hi @ngbusca ,

I have tested the given code with tf-nightl(2.14.0-dev20230712) and its working fine for me. I can able to save and reload the model. Could you please check the attached gist and let me know whether the code is right one to reproduce the reported behaviour.

Thanks!

@SuryanarayanaY SuryanarayanaY added the stat:awaiting response Status - Awaiting response from author label Jul 13, 2023
@ngbusca
Copy link
Author

ngbusca commented Jul 17, 2023

Hi @SuryanarayanaY
Thanks for the response. Yes, the code is correct. I've downgraded to 2.13 and don't encounter the issue. I must have had an inconsistency on my system, I'll close the issue and reopen if I encounter it again.

@ngbusca ngbusca closed this as completed Jul 17, 2023
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:apis Highlevel API related issues comp:model Model related issues stat:awaiting response Status - Awaiting response from author type:bug Bug
Projects
None yet
Development

No branches or pull requests

2 participants