栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

tensor 张量

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

tensor 张量

在数学中,一个单独的数可以成为标量,一列或者一行数组可以称为向量,一个二维数组成为矩阵,矩阵中的每一个元素都可以被行和列的索引唯一确定,如果数组的维度超过2,那么我们可以称该数组为张量。但是在 pytorch 中,张量属于一种数据结构,它可以是一个标量、一个向量、一个矩阵,甚至是更高维的数组,所以 pytorch 中 tensor 和 numpy 库中的数组 ndarray 非常相似,在使用时也会经常将 pytorch 的相关计算和优化都是在 tensor 的基础上完成的。

在 torch 中 CPU 和 GPU 张量分别有 8 种数据类型

数据类型dtypeCPU tensorGPU tensor
32 位浮点型torch.float32 或 torch.floattorch.FloatTensortorch.cuda.FloatTensor
64 位浮点型torch.float64 或 torch.doubletorch.DoubleTensortorch.cuda.DoubleTensor
16 位浮点型torch.float16 或 torch.halftorch.HalfTensortorch.cuda.HalfTensor
8 位无符号整型torch.uint8torch.ByteTensortorch.cuda.ByteTensor
8 位有符号整型torch.int8torch.CharTensortorch.cuda.CharTensor
16 位有符号整型torch.int16 或 torch.shorttorch.ShortTensortorch.cuda.ShortTensor
32 位有符号整型torch.int32 或 torch.inttorch.IntTensortorch.cuda.IntTensor
64 位有符号整型torch.int64 或 torch.longtorch.LongTensortorch.cuda.LongTensor
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/714373.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号