浮点数的特征和()

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

我在自定义张量流操作类型中有一个Eigen TensorMap

Eigen::TensorMap<Eigen::Tensor<float, 1, 1, long int>, 16, Eigen::MakePointer>

从它的拣货号码工作:

float a = Tbuf(0);

但是如果想把它加到标量浮点数上去

float b = Tbuf.sum();

我收到了一个错误

word2vec_kernels.cc: In member function ‘virtual void tensorflow::NegTrainWord2vecOp::Compute(tensorflow::OpKernelContext*)’:
word2vec_kernels.cc:516:29: error: cannot convert ‘const Eigen::TensorReductionOp<Eigen::internal::SumReducer<float>, const Eigen::DimensionList<long int, 1ul>, const Eigen::TensorMap<Eigen::Tensor<float, 1, 1, long int>, 16, Eigen::MakePointer>, Eigen::MakePointer>’ to ‘float’ in initialization
          float b = Tbuf.sum();
c++ tensorflow eigen
1个回答
3
投票

好的,我忘记了张量需要首先进行评估。

float b = ((Eigen::Tensor<float, 0, 1, long int> )Tbuf.sum())(0);
© www.soinside.com 2019 - 2024. All rights reserved.