如何在基础(根)环境中安装 TensorFlow?我能找到的在 Anaconda 中设置 Tensorflow 的唯一说明是创建一个新环境,tf如下所示:
conda create -n tf tensorflow,
conda activate tf
Run Code Online (Sandbox Code Playgroud)
然后当我运行我的代码时,我得到
ModuleNotFoundError: No module named 'tensorflow'.
Run Code Online (Sandbox Code Playgroud)
似乎在环境中没有找到 Tensorflow 模块tf。
如果我们<<一个torch::Tensor
#include <torch/script.h>
int main()
{
torch::Tensor input_torch = torch::zeros({2, 3, 4});
std::cout << input_torch << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我们看
(1,.,.) =
0 0 0 0
0 0 0 0
0 0 0 0
(2,.,.) =
0 0 0 0
0 0 0 0
0 0 0 0
[ CPUFloatType{2,3,4} ]
Run Code Online (Sandbox Code Playgroud)
如何获得张量形状(即2,3,4)?我在https://pytorch.org/cppdocs/api/classat_1_1_tensor.html?highlight=tensor中搜索了API 调用,但找不到。而且我搜索了operator<<重载代码,也没有找到。