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

时间:2019-03-14 13:30:59

标签: python tensorflow tensorboard

我修改了现有图形

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转换为tensorboard并尝试通过tensorboard查看它时

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'

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

0 个答案:

没有答案