-
Notifications
You must be signed in to change notification settings - Fork 191
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
TFFailedPreconditionException with BigGAN-deep model from TensorFlow Hub #365
Comments
I can replicate this. We know about the empty tags issue that you're working around with reflection, that'll get fixed soon, but I'm not sure why the SavedModelBundle has uninitialized variables in it. You can work around it by running We're currently working on the init ops to see if we can make it more compatible with TF Python's multiple incompatible ways of doing this, so we'll add this to the list of things to fix. FYI @rnett. For future reference/when I need to Google this later, I found the init op name by dumping all the ops to a file and grepping for "init" using this code in jshell: var itr = bundle.graph().operations();
try (PrintWriter w = new PrintWriter(new FileWriter("ops.txt"))) {
while (itr.hasNext()) {
var op = itr.next();
w.println(""+op);
}
} |
Adding |
I suspect this issue might be specific to GANs because they generate things, but I'm not sure if the naming of init nodes is consistent across different models. There might be something in the protobuf which names the init node that we haven't discovered yet. If it doesn't exist in the model you've loaded it will throw an exception, and if it does exist then it might re-initialize the weights zeroing out the training, so doing this blindly is a bad idea. |
That particular model is using TF1 stuff (see https://www.tensorflow.org/hub/api_docs/python/hub/Module deprecation notice), so I'm not sure whether that's something we can support automatically. I'll look into it though. @Craigacp where is your |
Yes, I loaded the Saved Model then pulled out the graph and iterated the operations to generate a list of the ops. |
Ok, this will definitely be handled by TF does variable restoration (from assets) before running init ops, which imo seems backwards, so we'll have to work around that. |
FYI @Craigacp @rnett I've noticed other TF1 models sometimes require multiple named init ops e.g. |
Looks like the table initializers are stored in a specific place in TF Hub v1 models - https://github.com/tensorflow/hub/blob/67f62bc46f58ccceabeec6fd6799236675f50f04/tensorflow_hub/native_module.py#L486, referencing https://github.com/tensorflow/tensorflow/blob/5dcfc51118817f27fad5246812d83e5dccdc5f72/tensorflow/python/framework/ops.py#L6174. Then it initializes the rest of the variables from the checkpoint https://github.com/tensorflow/hub/blob/c8403953fdd429ea4c9ad1a96869eef4182a3b6f/tensorflow_hub/native_module.py#L458. Presumably we could iterate the |
Should be easy enough to do, but I think it's better done as part of |
System information
Issue
I am able to load this biggan-deep model into java with the SavedModelBundle.Loader but when I run it, I get
The model works in Python. I initially encountered the issue when I used DJL to load and run the model. I tried it with TF-Java to see if the issue is in DJL or TF-Java.
Describe the expected behavior
The model should run fine just like in python.
Java code to reproduce the issue
The main method and the
loadModel(...)
are the important ones, the rest are just tensor operations.build.gradle:
Other info / logs
Console output:
The text was updated successfully, but these errors were encountered: