将tf.identity ops添加到现有图形中

问题描述 投票:1回答:1

我已经修改了现有图形

https://github.com/TropComplique/FaceBoxes-tensorflow/blob/master/src/detector.py#L70

添加tf.identity操作以获得可读的名称,然后在图形中找到它们。

with tf.name_scope('postprocessing'):
    boxes = batch_decode(self.box_encodings, self.anchors)
    # if the images were padded we need to rescale predicted boxes:
    boxes = boxes / self.box_scaler
    boxes = tf.clip_by_value(boxes, 0.0, 1.0)
    # it has shape [batch_size, num_anchors, 4]

    scores = tf.nn.softmax(self.class_predictions_with_background, axis=2)[:, :, 1]
    # it has shape [batch_size, num_anchors]

    boxes = tf.identity(input=boxes, name="my_boxes")
    scores = tf.identity(input=scores, name="my_scores")

然后有了现有的检查点,我使用此修改后的图形将检查点转换为.pb,如下所示:https://github.com/TropComplique/FaceBoxes-tensorflow/issues/6

但是当我尝试通过https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/import_pb_to_tensorboard.py将.pb转换为张量板,然后尝试通过张量板查看它时>]

python import_pb_to_tensorboard.py --model_dir model_v3.pb --log_dir model_v3_log_dir

2019-03-14 16:28:43.572017: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 418, in import_graph_def
    graph._c_graph, serialized, options)  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Node 'nms/map/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3' expects to be colocated with unknown node 'postprocessing/my_boxes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "import_pb_to_tensorboard.py", line 86, in <module>
    app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "import_pb_to_tensorboard.py", line 68, in main
    import_to_tensorboard(FLAGS.model_dir, FLAGS.log_dir)
  File "import_pb_to_tensorboard.py", line 59, in import_to_tensorboard
    importer.import_graph_def(graph_def)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 422, in import_graph_def
    raise ValueError(str(e))
ValueError: Node 'nms/map/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3' expects to be colocated with unknown node 'postprocessing/my_boxes'

因此可以为现有图形的某些操作设置可读名称吗?

我修改了现有图形https://github.com/TropComplique/FaceBoxes-tensorflow/blob/master/src/detector.py#L70添加tf.identity ops以获取可读的名称,然后在图形中找到它们。 ...

python tensorflow tensorboard
1个回答
0
投票

[尝试将Transformer模型图转换为量化版本时遇到了与您相同的错误。你解决了吗?您愿意分享您的解决方案吗?谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.