自己開發了一個股票智能分析軟件,功能很強大,需要的點擊下面的鏈接獲取:
https://www.cnblogs.com/bclshuai/p/11380657.html
1.1.1 常用數據類型
整型有符號 |
tf.int8:8位整數。 tf.int16:16位整數。 tf.int32:32位整數。 tf.int64:64位整數。 |
整型無符號 |
tf.uint8:8位無符號整數。 tf.uint16:16位無符號整數。tf.uint32,tf.uint64 |
浮點型 |
tf.float16:16位浮點數。 tf.float32:32位浮點數。 tf.float64:64位浮點數。 tf.double:等同於tf.float64。 |
字符串 |
tf.string:字符串 |
布爾 |
tf.bool:布爾型。True和False |
負數 |
tf.complex64:64位復數。 tf.complex128:128位復數。 |
1.1.2 tensorflow四種數據類型轉換方法
import tensorflow as tf ss = tf.compat.v1.Session() #保證sess.run()能夠正常運行,2.0不支持1.0的session tf.compat.v1.disable_eager_execution() a=10 print(a) b=tf.constant(a,dtype=tf.float64) #(1)constant指定數據類型轉變 print(b)#Tensor("Const:0", shape=(), dtype=float64) print(ss.run(b))#10.0 #(2)通過to_int32_tf.to_int64, tf.to_float, tf.to_double轉換 c=tf.compat.v1.to_int64(b); print(c)#Tensor("ToInt64:0", shape=(), dtype=int64) print(ss.run(c))#10 #(3)通過cast函數去轉換 d=tf.cast(a, tf.int8)#10,如果是65536則溢出,輸出結果為0 print(ss.run(d)) #(4)飽和轉換(大數字轉小類型,安全轉換) e=tf.saturate_cast(65536,dtype=tf.int8); print(ss.run(e))#輸出127