-
-
Save csvance/d9ce23fa386c452f7d955925e21aaa92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi, I am unable to convert many mainstream deep neural network architectures in Keras / Tensorflow from .pb to .uff because the conversion tool "convert_to_uff.py" throws an error about how parts of the Batch Normalization layer are not supported. | |
This effects bog standard CNN architectures such as GoogleNet / Inception_V3 which are obviously supported in Caffe. | |
Here is the .pb I used for conversion: https://www.dropbox.com/s/pu98bi9q87lz9mq/inception_v3.pb?dl=0 | |
Here is the way I am exporting the graph: https://gist.github.com/csvance/a1728337d273c8a1536fd80852857337 | |
I have no problems importing networks from Caffe trained by nVidia DIGITS which use Batchnorm. I also have no problem importing networks which do not use the Batchnorm layer. | |
--Log-- | |
root@4f42b39d20e9:/usr/lib/python2.7/dist-packages/uff/bin# python convert_to_uff.py tensorflow -o /Git/inception_v3.uff --input-file /Git/inception_v3.pb -O predictions/Softmax --input-file /Git/inception_v3.pb -O pr | |
Loading /Git/inception_v3.pb | |
Using output node predictions/Softmax | |
Converting to UFF graph | |
Warning: No conversion function registered for layer: Merge yet. | |
Converting as custom op Merge batch_normalization_94/cond/Merge | |
name: "batch_normalization_94/cond/Merge" | |
op: "Merge" | |
input: "batch_normalization_94/cond/batchnorm/add_1" | |
input: "batch_normalization_94/cond/Switch_1:1" | |
attr { | |
key: "N" | |
value { | |
i: 2 | |
} | |
} | |
attr { | |
key: "T" | |
value { | |
type: DT_FLOAT | |
} | |
} | |
Warning: No conversion function registered for layer: Switch yet. | |
Converting as custom op Switch batch_normalization_94/cond/Switch_1 | |
name: "batch_normalization_94/cond/Switch_1" | |
op: "Switch" | |
input: "batch_normalization_94/FusedBatchNorm" | |
input: "batch_normalization_94/cond/pred_id" | |
attr { | |
key: "T" | |
value { | |
type: DT_FLOAT | |
} | |
} | |
attr { | |
key: "_class" | |
value { | |
list { | |
s: "loc:@batch_normalization_94/FusedBatchNorm" | |
} | |
} | |
} | |
Warning: No conversion function registered for layer: PlaceholderWithDefault yet. | |
Converting as custom op PlaceholderWithDefault batch_normalization_1/keras_learning_phase | |
name: "batch_normalization_1/keras_learning_phase" | |
op: "PlaceholderWithDefault" | |
input: "batch_normalization_1/keras_learning_phase/input" | |
attr { | |
key: "dtype" | |
value { | |
type: DT_BOOL | |
} | |
} | |
attr { | |
key: "shape" | |
value { | |
shape { | |
} | |
} | |
} | |
Traceback (most recent call last): | |
File "convert_to_uff.py", line 109, in <module> | |
main() | |
File "convert_to_uff.py", line 104, in main | |
output_filename=args.output | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/conversion_helpers.py", line 103, in from_tensorflow_frozen_model | |
return from_tensorflow(graphdef, output_nodes, **kwargs) | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/conversion_helpers.py", line 75, in from_tensorflow | |
name="main") | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 64, in convert_tf2uff_graph | |
uff_graph, input_replacements) | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 51, in convert_tf2uff_node | |
op, name, tf_node, inputs, uff_graph, tf_nodes=tf_nodes) | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 28, in convert_layer | |
fields = cls.parse_tf_attrs(tf_node.attr) | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 177, in parse_tf_attrs | |
for key, val in attrs.items()} | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 177, in <dictcomp> | |
for key, val in attrs.items()} | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 172, in parse_tf_attr_value | |
return cls.convert_tf2uff_field(code, val) | |
File "/usr/lib/python2.7/dist-packages/uff/converters/tensorflow/converter.py", line 161, in convert_tf2uff_field | |
if shp.unknown_rank: | |
AttributeError: 'google.protobuf.pyext._message.RepeatedCompositeCo' object has no attribute 'unknown_rank' | |
root@4f42b39d20e9:/usr/lib/python2.7/dist-packages/uff/bin# | |
--Operating System Info-- | |
docker pull chybhao666/cuda9_cudnn7_tensorrt3.0:latest | |
root@4f42b39d20e9:~# lsb_release -a | |
No LSB modules are available. | |
Distributor ID: Ubuntu | |
Description: Ubuntu 16.04.3 LTS | |
Release: 16.04 | |
Codename: xenial | |
root@4f42b39d20e9:~# dpkg -l | grep -i tensor | |
ii libnvinfer-dev 4.0.1-1+cuda9.0 amd64 TensorRT development libraries and headers | |
ii libnvinfer-samples 4.0.1-1+cuda9.0 amd64 TensorRT samples and documentation | |
ii libnvinfer4 4.0.1-1+cuda9.0 amd64 TensorRT runtime libraries | |
ii nv-tensorrt-repo-ubuntu1604-ga-cuda9.0-trt3.0-20171128 1-1 amd64 nv-tensorrt repository configuration files | |
iU python-libnvinfer 4.0.1-1+cuda9.0 amd64 Python bindings for TensorRT | |
iU python-libnvinfer-dev 4.0.1-1+cuda9.0 amd64 Python development package for TensorRT | |
ii tensorrt 3.0.1-1+cuda9.0 amd64 Meta package of TensorRT | |
ii uff-converter-tf 4.0.1-1+cuda9.0 amd64 UFF converter for TensorRT package |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment