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

ValueError: Graph has cycles. #124

Closed
MatthewWaller opened this issue Feb 7, 2018 · 13 comments
Closed

ValueError: Graph has cycles. #124

MatthewWaller opened this issue Feb 7, 2018 · 13 comments
Labels
feature request Functionality does not currently exist, would need to be created as a new feature (type)

Comments

@MatthewWaller
Copy link

Hello, and thank you so much for this huge undertaking! I'm working on trying to convert Mozilla's DeepSpeech pre-trained model, and I get the error: "ValueError: Graph has cycles."

Any ideas about what I could do for this? Are graphs with cycles simply not going to work?

@aseemw
Copy link
Collaborator

aseemw commented Feb 7, 2018

CoreML does not support graphs with cycles at the moment. However, it does support recurrent nodes (RNN, LSTM, GRU etc). When these cells are implemented in TF, they get broken down into cyclic graphs in the frozen .pb file. tfcoreml cannot handle such graphs at the moment. This is a known issue currently. Handling such graphs would require going from the broken down graph structure to the higher level structure and mapping the nodes to an operation that CoreML supports (RNN, LSTM etc).

I think the simplest way to deal with such graphs for now is to abstract the weight matrices and bias vectors from pre-trained TF. And then use them to build a CoreML model directly using the neural network builder API provided by coremltools.

@aseemw aseemw added the feature request Functionality does not currently exist, would need to be created as a new feature (type) label Feb 7, 2018
@chinmay5
Copy link

What about a YOLO model then? It should work fine in that case right?

@aseemw
Copy link
Collaborator

aseemw commented May 28, 2018

Yes, YOLO model does not have cycles, so that should work.

@mbenami
Copy link

mbenami commented Jun 13, 2018

what about Faster-rcnn?

@younatics
Copy link

younatics commented Jun 21, 2018

@aseemw Do you have any plan to support tf.nn.bidirectional_dynamic_rnn?

@tianranwangcs
Copy link

@aseemw Any plan to support BLSTM?

@i-asimkhan
Copy link

@aseemw Could you please tell me about a frozen_inference_graph.pb created with the help of Tensorflow.
I haven't converted it to be used for Mobile Apps. But I directly tried it to be converted into .MlModel with TensorFlowtoCoreML.
Gave me the same error.

@eaigner
Copy link

eaigner commented Jul 11, 2018

+1 for BiRNN support

@asevko
Copy link

asevko commented Sep 11, 2018

@aseemw

And then use them to build a CoreML model directly using the neural network builder API provided by coremltools.

Your provided API link doesn't work (404). Can you give a working one?

@aseemw
Copy link
Collaborator

aseemw commented Sep 11, 2018

This is link: https://apple.github.io/coremltools/generated/coremltools.models.neural_network.builder.html

@mrgloom
Copy link

mrgloom commented Mar 11, 2019

I wonder where ssd model contains cycles? it look like just as feedforward network.

WARNING:root:TensorFlow version 1.12.0 detected. Last version known to be fully compatible is 1.5.0 .

Loading the TF graph...
2019-03-11 12:34:45.237621: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Graph Loaded.
Traceback (most recent call last):
  File "ssd_sandbox/convert_from_tensorflow_to_coreml.py", line 20, in <module>
    convert_from_tensorflow_to_coreml(is_post_training_quantize=False)
  File "ssd_sandbox/convert_from_tensorflow_to_coreml.py", line 10, in convert_from_tensorflow_to_coreml
    'detection_classes:0', 'num_detections:0'])
  File "/usr/local/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 586, in convert
    custom_conversion_functions=custom_conversion_functions)
  File "/usr/local/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 167, in _convert_pb_to_mlmodel
    OPS = _topological_sort_ops(OPS)
  File "/usr/local/lib/python3.6/site-packages/tfcoreml/_tf_graph_transform.py", line 194, in _topological_sort_ops
    _push_stack(stack, node, in_stack)
  File "/usr/local/lib/python3.6/site-packages/tfcoreml/_tf_graph_transform.py", line 38, in _push_stack
    raise ValueError('Graph has cycles.')
ValueError: Graph has cycles.

@Mstronach
Copy link
Collaborator

This issue is being closed due to inactivity preceeding the request for an update. Please feel free to re-open. Thanks!

@dhgokul
Copy link

dhgokul commented Apr 9, 2020

Me too got same error as mentioned by @Mstronach
We used SSD mobilenet version and generate protobuf file and tried to convert ML model we get same issue - PFA
image

Any updates on this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Functionality does not currently exist, would need to be created as a new feature (type)
Projects
None yet
Development

No branches or pull requests