tensorflow(一)


一、安裝

pip install tensorflow

二、簡介

tensor是張量的意思,flow是流動

張量是數據的載體,包括標量,向量,矩陣,數據立方,n維的數據

tensorflow的數據流圖,用節點和有向邊描述數學運算的有向無環圖,圖中節點代表操作,具體包括數學運算,數據填充,結果輸出和變量讀寫,有向邊描述了節點的輸入和輸出的關系,邊上流動這張量的數據。

1.節點分類

數學函數或表達式:MatMul、BiasAdd、Softmax

存儲模型參數的變量:ReLu Layer

占位符:Input Class Labels

梯度值

更新模型參數

2.有向邊

有向邊用於定義操作之間的關系,分為兩類,一類用來傳輸數據,另一類用來定義控制依賴

三、demo

import tensorflow as tf
hello = tf.constant('hello ,tensorflow!')
sess = tf.Session()
print(sess.run(hello))

sp = tf.SparseTensor(indices=[[0,2],[1,3]],values=[1,2],dense_shape=[3,4])

x = tf.SparseTensor(indices = [[0,0],[0,2],[1,1]],values=[1,1,1],dense_shape=[2,3])

tf.sparse_reduce_sum(x,axis=1,keep_dims=True)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM