tensorflow常用技巧

2021-08-21 23:47:37 字數 388 閱讀 2251

vim ~/.vimrc 開啟這個檔案後

設定tab鍵為4個空格,並且每行顯示行號。

輸入:set nu#設定每行行號

set ts=4#空四個空格

建立計算圖,這是不會顯示計算結果,只描述了這是什麼樣的計算

import tensorflow as tf

a=tf.constant([[1.0,2.0]])

b=tf.constant([[3.0],[4.0]])

result=tf.matmul(a,b)

print result

執行計算圖中的結點運算

with tf.session() as sess:

print sess.run(result)

TensorFlow除錯技巧

tensorflow從誕生以來就一直在深度學習框架中穩居老大的位置,雖然自從2018年12月pytorch 1.0 stable版本正式發布以來,很快減小了差距,但是也難以超越。tensorflow的強項在於部署 包括tensorflow lite在移動端部署 和執行效率,另外對各種operatio...

tensorflow常用函式

1.variable 主要在於一些可訓練變數 trainable variables 比如模型的權重 weights 或者偏執值 bias 1 宣告時,必須提供初始值 2 在真實訓練時,其值是會改變的,自然事先需要指定初始值 weights tf.variable tf.random normal ...

TensorFlow常用函式

使用tensorflow計算流程 1 prepare train data 2 define model and graph 3 choose optimizer 4 create a session to run import tensorflow as tf 1.tf.reduce mean i...