1. 程式人生 > >TensorFlow框架(一) 張量、計算圖、會話

TensorFlow框架(一) 張量、計算圖、會話

type ont 權重 src target col flow imp mooc

參考:中國大學MOOC 北京大學 曹健《TensorFlow筆記》


基於TensorFlow的NN:用張量表示數據,用計算圖搭建神經網絡,用會話執行計算圖,優化線上的權重(參數),得到模型。

張量(tensor):多維數組

階:張量的維數


維數  階  名字  例子

0-D   0  標量 s=1 2 3

1-D   1   向量   v=[1,2,3]

2-D   2   矩陣   m=[[1,2,3],[4,5,6]]

3-D   3   張量   t=[[...

張量可以表示0階到n階的數組(列表)


import tensorflow as tf
a 
= tf.constant([1.0,2.0]) b = tf.constant([3.0,4.0]) result = a + b print result

技術分享圖片

計算圖只描述計算過程,不計算結果。

技術分享圖片

TensorFlow框架(一) 張量、計算圖、會話