Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TensorFlow:如何将值包装为标量张量而不是1x1张量_Python_C++_Tensorflow - Fatal编程技术网

Python TensorFlow:如何将值包装为标量张量而不是1x1张量

Python TensorFlow:如何将值包装为标量张量而不是1x1张量,python,c++,tensorflow,Python,C++,Tensorflow,我有以下代码,试图将bool值包装成tensorflow::Tensor tensorflow::Tensor vector_to_tensor_bool(const std::vector<bool> &input_vec) { tensorflow::Tensor tensor_1d(tensorflow::DT_BOOL, tensorflow::TensorShape({1})); auto tensor_1d_map = tensor_1d.tens

我有以下代码,试图将
bool
值包装成tensorflow::Tensor

tensorflow::Tensor vector_to_tensor_bool(const std::vector<bool> &input_vec) {
    tensorflow::Tensor tensor_1d(tensorflow::DT_BOOL, tensorflow::TensorShape({1}));
    auto tensor_1d_map = tensor_1d.tensor<bool, 1>();
    tensor_1d_map(0) = input_vec[0];
    return tensor_1d;
}
我想它是说我应该把它变成标量张量,而不是1x1张量。如何将正则值转换为标量张量值?谢谢

 Caused by: Invalid argument: The second input must be a scalar, but it has shape [1]