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

Loading The graph model #11

Open
ghost opened this issue Oct 12, 2021 · 2 comments
Open

Loading The graph model #11

ghost opened this issue Oct 12, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 12, 2021

Hi, whenever I try to load the model I get the following error.
can you please help me resolve this matter plese? thank you.

ValueError: Node 'gradients/UNet/conv0_up/batch_normalization_3/FusedBatchNorm_grad/FusedBatchNormGrad' has an _output_shapes attribute inconsistent with the GraphDef for output #3: Dimension 0 in both shapes must be equal, but are 0 and 16. Shapes are [0] and [16]

@tramanhphambme
Copy link

Hi, there. I just recently tried the code and also got the same issue. Could you tell me if you fix it yet? Thank you!!

@iimog
Copy link

iimog commented Aug 31, 2022

A similar problem was reported elsewhere, and the their fix works here, as well.

@@ -50,11 +50,17 @@ tf.app.flags.DEFINE_float('weight_r', 0.1,
 
 
 if __name__ == '__main__':
+    gd = tf.MetaGraphDef()
+    with open('{0}.meta'.format(FLAGS.model_path), "rb") as f:
+        gd.ParseFromString(f.read())
+    for node in gd.graph_def.node:
+        if '_output_shapes' in node.attr:
+            del node.attr['_output_shapes']
     with tf.Session() as sess:
         sess.run(tf.global_variables_initializer())
 
         # Import the computation graph and restore the variable values
-        saver = tf.train.import_meta_graph('{0}.meta'.format(FLAGS.model_path))
+        saver = tf.train.import_meta_graph(gd)
         saver.restore(sess, '{0}'.format(FLAGS.model_path))
 
         print('Start evaluating on the test set ...')

With these changes in deploy_network_ao.py and deploy_network.py it works for me.

iimog added a commit to BioMeDS/ukbb_cardiac that referenced this issue Sep 1, 2022
dropping the conflicting _output_shapes node attributes
Fix baiwenjia#11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants