2017-09-06 57 views
0

我感兴趣的是得到它定义为指针的输出张量的值:如何获得指针型张量的形状?

Tensor* out = nullptr;

我试图out->get_shape()会抛出错误:

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

如何获得形状?

+0

你可以试试,'OUT->形状()'; –

+0

我试图打印使用:'std :: cout <<“out =”<< out-> shape()<< std :: endl;'。它说:'错误:'operator <<'不匹配(操作数类型是'std :: basic_ostream '和'const tensorflow :: TensorShape')' – NamrataB

回答

0

可以使用'shape()'温控功能访问张的形状,它会返回一个TensorShape,打印的值,你可以使用.vec()方法

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

'错误:'const class tensorflow :: TensorShape'has no member命名为'vec'.'s ..这是在最新版本中添加的? M使用1.2.1 – NamrataB

+0

'dim_sizes'必须工作。 '.vec'是张量,看起来Tensorshape在这里不被认为是张量。 –

+0

我试过 - >昏暗(),它的工作。谢谢你的帮助! – NamrataB