类型的自定义tensorflow操作中有一个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();发布于 2018-03-02 20:20:10
好吧,我忘记了张量首先需要计算。
float b = ((Eigen::Tensor<float, 0, 1, long int> )Tbuf.sum())(0);https://stackoverflow.com/questions/49068802
复制相似问题