如何获得指针类型张量的形状?

时间:2017-09-06 06:51:29

标签: tensorflow

我感兴趣的是获取输出张量的值,该值被定义为指针:

Tensor* out = nullptr;

我尝试out->get_shape()会引发错误:

error: 'class tensorflow::Tensor' has no member named 'get_shape'; did you mean 'set_shape'?

如何塑造形状?

1 个答案:

答案 0 :(得分:0)

您可以使用'shape()'功能访问张量的形状,它将返回TensorShape,以打印您可以使用的值.vec()方法

const TensorShape& out_shape = out.shape();
std::cout << "out = " << out_shape.dim_sizes() << std::endl;