如何通过火炬Lua修改张量数据类型?

2026-04-01 20:020阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计145个文字,预计阅读时间需要1分钟。

如何通过火炬Lua修改张量数据类型?

我创建了从1到3的数字排列。`th=y=torch.randperm(3); y=[3, 2, 1][torch.DoubleTensor of size 3]`。现在,我想将`y`转换成`Torch.LongTensor`。我该如何做到这一点?

`y=y.long()` 完成转换。其他数据类型转换有类似的方法。

我创建了从1到3的数字排列.

th> y = torch.randperm(3 ); th> y 3 2 1 [torch.DoubleTensor of size 3]

现在,我想将y转换为Torch.LongTensor.我怎样才能做到这一点?

如何通过火炬Lua修改张量数据类型?

y = y:long()完成工作.其他数据类型有类似的方法,如int,char,float和byte

本文共计145个文字,预计阅读时间需要1分钟。

如何通过火炬Lua修改张量数据类型?

我创建了从1到3的数字排列。`th=y=torch.randperm(3); y=[3, 2, 1][torch.DoubleTensor of size 3]`。现在,我想将`y`转换成`Torch.LongTensor`。我该如何做到这一点?

`y=y.long()` 完成转换。其他数据类型转换有类似的方法。

我创建了从1到3的数字排列.

th> y = torch.randperm(3 ); th> y 3 2 1 [torch.DoubleTensor of size 3]

现在,我想将y转换为Torch.LongTensor.我怎样才能做到这一点?

如何通过火炬Lua修改张量数据类型?

y = y:long()完成工作.其他数据类型有类似的方法,如int,char,float和byte