转换后的Tensorrt模型与Tensorflow模型具有不同的输出形状吗?

时间:2019-06-03 15:08:01

标签: tensorflow tensorrt

我有一个tensorflow模型并转换为tensorrt模型。 Tensorflow模型的uff转换如下所示。输入是图像,输出是Openpose / concat_stage7

NOTE: UFF has been tested with TensorFlow 1.12.0. Other versions are not guaranteed to work
UFF Version 0.6.3
=== Automatically deduced input nodes ===
[name: "image"
op: "Placeholder"
attr {
  key: "dtype"
  value {
    type: DT_FLOAT
  }
}
attr {
  key: "shape"
  value {
    shape {
      dim {
        size: -1
      }
      dim {
        size: -1
      }
      dim {
        size: -1
      }
      dim {
        size: 3
      }
    }
  }
}
]
=========================================

=== Automatically deduced output nodes ===
[name: "Openpose/concat_stage7"
op: "ConcatV2"
input: "Mconv7_stage6_L2/BiasAdd"
input: "Mconv7_stage6_L1/BiasAdd"
input: "Openpose/concat_stage7/axis"
attr {
  key: "N"
  value {
    i: 2
  }
}
attr {
  key: "T"
  value {
    type: DT_FLOAT
  }
}
attr {
  key: "Tidx"
  value {
    type: DT_INT32
  }
}
]
==========================================

Using output node Openpose/concat_stage7
Converting to UFF graph
No. nodes: 463
UFF Output written to cmu/cmu_openpose.uff

Tensorflow模型的输出形状为

self.tensor_output = self.graph.get_tensor_by_name('TfPoseEstimator/Openpose/concat_stage7:0')
(?, ?, ?, 57)

当我运行tensorrt时,输出尺寸为(217500,)? 如何具有与Tensorflow模型相同的尺寸?

1 个答案:

答案 0 :(得分:0)

是的,现在一切都解决了,我可以在TensorRT中产生与Tensorflow模型输出相同的结果。

问题是TensorRT以展平格式生成输出数组。需要根据需要重塑尺寸。

所以我要做的是检查Tensorflow输出的尺寸并相应地调整形状。