由於tensorflow版本迭代較快且不同版本的接口會有差距,我這里使用的是1.14.0的版本
安裝指定版本的方法:pip install tensorflow==1.14.0 如果你之前安裝高版本(比如2.1.0),它會自動把高版本卸載掉
import tensorflow as tf m1=tf.constant([[3,3]]) #創建一個常量op m2=tf.constant([[2],[3]]) product=tf.matmul(m1,m2) #創建一個矩陣乘法op,把m1和m2傳入 print (product) #這里將輸出一個Tensor #定義一個會話1,啟動默認圖 sess=tf.Session() #舊版本 result=sess.run(product) #調用run方法來執行矩陣乘法 print(result) sess.close() #另一種定義會話的方式(常用) with tf.Session() as sess: result=sess.run(product) print(result)
目錄:
- tensorflow簡介、目錄
- tensorflow中的圖(02-1)
- tensorflow變量的使用(02-2)
- tensorflow中的Fetch、Feed(02-3)
- tensorflow版helloworld---擬合線性函數的k和b(02-4)
- tensorflow非線性回歸(03-1)
- MNIST手寫數字分類simple版(03-2)
- 二次代價函數、交叉熵(cross-entropy)、對數似然代價函數(log-likelihood cost)(04-1)
- 多層網絡通過防止過擬合,增加模型的准確率(04-2)
- 修改優化器進一步提升准確率(04-3)
- 手寫數字識別-卷積神經網絡cnn(06-2)
- 循環神經網絡rnn與長短時記憶神經網絡簡述(07-2)
- 循環神經網絡lstm代碼實現(07-3)
- tensorflow模型保存和使用08
- 下載inception v3 google訓練好的模型並解壓08-3
- 使用inception v3做各種圖像分類識別08-4
- word2vec模型訓練簡單案例
- word2vec+textcnn文本分類簡述及代碼