相关疑难解决方法(0)

将张量列表转换为张量的张量 pytorch

我有这个代码:

import torch

list_of_tensors = [ torch.randn(3), torch.randn(3), torch.randn(3)]
tensor_of_tensors = torch.tensor(list_of_tensors)
Run Code Online (Sandbox Code Playgroud)

我收到错误:

ValueError:只有一个元素张量可以转换为Python标量

如何将张量列表转换为pytorch中的张量张量?

python python-3.x pytorch

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

python-3.x ×1

pytorch ×1