Tensorflow初學基本操作

2021-09-02 00:09:50 字數 621 閱讀 6442

比如有temp_var = tf.variable([[1,2,3], [4,5,6], [7,8,9], [10,11,12]])

想要取出來的行為idx = tf.constant([0,2])

那麼相應的操作為:rows = tf.gather(temp_var, idx)

gather_nd 比gather還要更強勢

def top_k(input, k=1, sorted=true, name=none)
查詢最後乙個維度的前k個最大條目的值和索引。

注:該函式返回的資料報含兩部分,第一部分是返回的value值,第二部分返回的是對應的索引值。可以通過索引[0]或者[1]進行訪問。

養成在tf.xx()裡面加上 name = xx的習慣!

t0=tf.constant([[0,0],[1,1]])

t1 = tf.expand_dims(t0, axis=-1)

t=tf.constant([[[0],[0]],[[1],[1]]])

這樣的話更新啥的還是比較方便 分成小的再湊起來總會是有問題的

機器學習 TensorFlow初學

dot 陣列的點積 dot producta np.arange 0,9 out 45 array 0,1,2,3,4,5,6,7,8 b a 1 out 47 array 8,7,6,5,4,3,2,1,0 np.dot a,b out 48 84隨機數生成 這幾個都是用於生成隨機數tensor的...

Selenium webdriver基本操作1

usr bin env python coding utf 8 from selenium import webdriver import time print 瀏覽器最大化 生成driver物件 driver webdriver.firefox 將瀏覽器最大化 driver.maximize wi...

TensorFlow初學者了解

參考 tensorflow 是乙個程式設計系統,你也可以把他理解成乙個機器學習的庫或者是框架 1 幾個概念 tensor 張量 session 會話 placeholder 佔位符 variable 變數 graph 圖 feed和fetch 機制 1 圖 graph 用來表示計算任務,也就我們要做...