校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > pytorch常用數據類型所占字節數對照表一覽

pytorch常用數據類型所占字節數對照表一覽

熱門標簽:廣告地圖標注app 激戰2地圖標注 唐山智能外呼系統一般多少錢 海南400電話如何申請 騰訊外呼線路 哈爾濱ai外呼系統定制 白銀外呼系統 陜西金融外呼系統 公司電話機器人

PyTorch上的常用數據類型如下

Data type dtype CPU tensor GPU tensor Size/bytes
32-bit floating torch.float32 or torch.float torch.FloatTensor torch.cuda.FloatTensor 4
64-bit floating torch.float64 or torch.double torch.DoubleTensor torch.cuda.DoubleTensor 8
16-bit floating torch.float16or torch.half torch.HalfTensor torch.cuda.HalfTensor -
8-bit integer (unsigned) torch.uint8 torch.ByteTensor torch.cuda.ByteTensor 1
8-bit integer (signed) torch.int8 torch.CharTensor torch.cuda.CharTensor -
16-bit integer (signed) torch.int16or torch.short torch.ShortTensor torch.cuda.ShortTensor 2
32-bit integer (signed) torch.int32 or torch.int torch.IntTensor torch.cuda.IntTensor 4
64-bit integer (signed) torch.int64 or torch.long torch.LongTensor torch.cuda.LongTensor 8

以上PyTorch中的數據類型和numpy中的相對應,占用字節大小也是一樣的

補充:pytorch tensor比較大小 數據類型要注意

如下

a = torch.tensor([[0, 0], [0, 0]])
print(a>=0.5)

輸出

tensor([[1, 1],

[1, 1]], dtype=torch.uint8)

結果明顯不對, 分析原因是因為, a是long類型, 而0.5是float. 0.5會被轉化為 long, 變為0. 因此結果會出錯, 做出如下修改就可以得到正確答案

正確用法:

a = torch.tensor([[0, 0], [0, 0]]).float()
print(a>=0.5)

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • PyTorch基本數據類型(一)
  • pytorch常見的Tensor類型詳解
  • PyTorch中Tensor的數據類型和運算的使用
  • Pytorch 實現變量類型轉換

標簽:惠州 常德 四川 上海 鷹潭 黑龍江 黔西 益陽

巨人網絡通訊聲明:本文標題《pytorch常用數據類型所占字節數對照表一覽》,本文關鍵詞  pytorch,常用,數據,類型,所占,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《pytorch常用數據類型所占字節數對照表一覽》相關的同類信息!
  • 本頁收集關于pytorch常用數據類型所占字節數對照表一覽的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 韩城市| 故城县| 通州市| 永登县| 镇原县| 陇南市| 彰化县| 班玛县| 青神县| 兴业县| 滕州市| 朝阳区| 中卫市| 永康市| 施秉县| 孙吴县| 蓝山县| 西藏| 靖江市| 淄博市| 萍乡市| 嘉义县| 荣昌县| 搜索| 淳化县| 班戈县| 论坛| 新晃| 景洪市| 双辽市| 孟津县| 河曲县| 唐山市| 朝阳县| 蓝田县| 曲水县| 河北区| 神池县| 志丹县| 荥经县| 潞西市|