tensorflow中的數(shù)據(jù)類型dtype用法說明
Tensorflow中,主要有以下幾種數(shù)據(jù)類型(dtype),在舊版本中,不用加tf也能使用。
有符號(hào)整型
tf.int8:8位整數(shù)。
tf.int16:16位整數(shù)。
tf.int32:32位整數(shù)。
tf.int64:64位整數(shù)。
無符號(hào)整型
tf.uint8:8位無符號(hào)整數(shù)。
tf.uint16:16位無符號(hào)整數(shù)。
浮點(diǎn)型
tf.float16:16位浮點(diǎn)數(shù)。
tf.float32:32位浮點(diǎn)數(shù)。
tf.float64:64位浮點(diǎn)數(shù)。
tf.double:等同于tf.float64。
字符串型
tf.string:字符串。
布爾型
tf.bool:布爾型。
復(fù)數(shù)型
tf.complex64:64位復(fù)數(shù)。
tf.complex128:128位復(fù)數(shù)。
補(bǔ)充:tensorflow及numpy的數(shù)據(jù)類型對(duì)象Dtype總結(jié)
1.dtyte與astype
dtype:查看數(shù)據(jù)類型
astype:轉(zhuǎn)換數(shù)據(jù)類型
2.tensorlow數(shù)據(jù)類型對(duì)象Dtype
名稱 | 描述 |
---|---|
tf.float16 | 16位半精度浮點(diǎn) |
tf.float32 | 32位單精度浮點(diǎn) |
tf.float64 | 64位雙精度浮點(diǎn) |
tf.bfloat16 | 16位截?cái)喔↑c(diǎn) |
tf.complex64 | 64位單精度復(fù)數(shù) |
tf.complex128 | 128位雙精度復(fù)數(shù) |
tf.int8 | 8位有符號(hào)整數(shù) |
tf.uint8 | 8位無符號(hào)整數(shù) |
tf.uint16 | 16位無符號(hào)整數(shù) |
tf.int16 | 16位有符號(hào)整數(shù) |
tf.int32 | 32位有符號(hào)整數(shù) |
tf.int64 | 64位有符號(hào)整數(shù) |
tf.bool | 布爾值 |
tf.string | 字符串 |
tf.qint8 | 量化的8位帶符號(hào)整數(shù) |
tf.quint8 | 量化的8位無符號(hào)整數(shù) |
tf.qint16 | 量化的16位有符號(hào)整數(shù) |
tf.quint16 | 量化的16位無符號(hào)整數(shù) |
tf.qint32 | 量化的32位有符號(hào)整數(shù) |
tf.as_dtype()函數(shù)將numpy類型和字符串類型名稱轉(zhuǎn)換為DType對(duì)象。
3.numpy數(shù)據(jù)類型對(duì)象dtype
名稱 | 描述 |
---|---|
np.bool_ | 布爾型數(shù)據(jù)類型 |
np.int_ | 默認(rèn)的整數(shù)類型 |
np.intc | 與 C 的 int 類型一樣,一般是 int32 或 int 64 |
np.intp | 用于索引的整數(shù)類型,一般是 int32 或 int64 |
np.int8 | 8位整數(shù)即1字節(jié)(-128 to 127) |
np.int16 | 16位整數(shù)(-32768 to 32767) |
np.int32 | 32位整數(shù)(-2147483648 to 2147483647) |
np.int64 | 64位整數(shù)(-9223372036854775808 to 9223372036854775807) |
np.uint8 | 8位無符號(hào)整數(shù)(0 to 255) |
np.uint16 | 16位無符號(hào)整數(shù)(0 to 65535) |
np.uint32 | 32位無符號(hào)整數(shù)(0 to 4294967295) |
np.uint64 | 64位無符號(hào)整數(shù)(0 to 18446744073709551615) |
np.float_ | float64 簡寫,即64位雙精度浮點(diǎn)數(shù) |
np.float16 | 16位半精度浮點(diǎn)數(shù),包括:1 個(gè)符號(hào)位,5 個(gè)指數(shù)位,10 個(gè)尾數(shù)位 |
np.float32 | 32位 單精度浮點(diǎn)數(shù),包括:1 個(gè)符號(hào)位,8 個(gè)指數(shù)位,23 個(gè)尾數(shù)位 |
np.float64 | 64位雙精度浮點(diǎn)數(shù),包括:1 個(gè)符號(hào)位,11 個(gè)指數(shù)位,52 個(gè)尾數(shù)位 |
np.complex_ | complex128 簡寫,即 128 位復(fù)數(shù) |
np.complex64 | 復(fù)數(shù),表示雙 32 位浮點(diǎn)數(shù)(實(shí)數(shù)部分和虛數(shù)部分) |
np.complex128 | 復(fù)數(shù),表示雙 64 位浮點(diǎn)數(shù)(實(shí)數(shù)部分和虛數(shù)部分) |
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
flask使用session保存登錄狀態(tài)及攔截未登錄請求代碼
這篇文章主要介紹了flask使用session保存登錄狀態(tài)及攔截未登錄請求代碼,具有一定借鑒價(jià)值,需要的朋友可以參考下2018-01-01使用Python?matplotlib繪制簡單的柱形圖、折線圖和直線圖
Matplotlib是Python的繪圖庫, 它可與NumPy一起使用,提供了一種有效的MatLab開源替代方案,下面這篇文章主要給大家介紹了關(guān)于使用Python?matplotlib繪制簡單的柱形圖、折線圖和直線圖的相關(guān)資料,需要的朋友可以參考下2022-08-08如何利用Python處理excel表格中的數(shù)據(jù)
Excel做為職場人最常用的辦公軟件,具有方便、快速、批量處理數(shù)據(jù)的特點(diǎn),下面這篇文章主要給大家介紹了關(guān)于如何利用Python處理excel表格中數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2022-03-03python實(shí)例方法的使用注意及代碼實(shí)例
在本篇文章里小編給大家總結(jié)的是關(guān)于python實(shí)例方法的使用注意及代碼實(shí)例內(nèi)容,對(duì)此有興趣的朋友們可以參考下。2022-11-11