- 1.2-雙系統(tǒng)安裝
- 1.3-Windows虛擬機安裝
- 1.4-Mac Tensorflow安裝
- 2.1-Linux指令、Hello World
- 2.2-列表、元組、字典
- 2.3-條件語句
- 2.4-循環(huán)語句
- 2.5-turtle模塊
- 2.6-函數(shù)、模塊、包
- 2.7-類、對象、面向?qū)ο蟮木幊?/a>
- 2.8-文件操作
- 3.1-張量、計算圖、會話
- 3.2-前向傳播
- 3.3-反向傳播
- 4.1-損失函數(shù)
- 4.2-學習率
- 4.3-滑動平均
- 4.4-正則化
- 4.5-神經(jīng)網(wǎng)絡(luò)搭建八股
- 5.1-MNIST數(shù)據(jù)集
- 5.2-模塊化搭建神經(jīng)網(wǎng)絡(luò)八股
- 5.3-手寫數(shù)字識別準確率輸出
- 6.1-輸入手寫數(shù)字圖片輸出識別結(jié)果
- 6.2-制作數(shù)據(jù)集
- 7.1-卷積神經(jīng)網(wǎng)絡(luò)
- 7.2-lenet5代碼講解
- 8.1-復現(xiàn)已有的卷積神經(jīng)網(wǎng)絡(luò)
- 8.2-用vgg16實現(xiàn)圖片識別
這是人工智能入門課,將用八次課幫你梳理人工智能概念、機器學習方法、深度學習框架。如果你還不知道什么是人工智能、機器學習、深度學習,歡迎進來學習交流。結(jié)課時,你將會用Python搭建人工神經(jīng)網(wǎng)絡(luò),實現(xiàn)特定物體的識別。一起編碼感受人工智能 機器學習 深度學習吧!
什么是機器學習
如果一個程序可在任務(wù)T上,隨經(jīng)驗E的增加,效果P隨之增加,則認為這個程序可以從經(jīng)驗中學習。
Tensorflow
基于Tensorflow的神經(jīng)網(wǎng)絡(luò)
用張量表示數(shù)據(jù),用計算圖搭建神經(jīng)網(wǎng)絡(luò),用會話執(zhí)行計算圖,優(yōu)化線上的權(quán)重(參數(shù)),得到模型。
張量、計算圖、會話和簡單的Tensorflow例子
import tensorflow as tf a = tf.constant([1.0, 2.0])b = tf.constant([3.0, 4.0])result = a + bprint(result)with tf.Session() as sess: print(sess.run(result))
結(jié)果為:
Tensor("add_3:0", shape=(2,), dtype=float32)[4. 6.]再有
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))
結(jié)果為:
Tensor("MatMul:0", shape=(1, 1), dtype=float32)[[11.]]張量(tensor):多維數(shù)組(列表) 階:張量的維數(shù)
計算圖(Graph):搭建神經(jīng)網(wǎng)絡(luò)的計算過程,只搭建不運算
會話(Session):執(zhí)行計算圖中的節(jié)點運算
參數(shù) tf.Variable
w = tf.Variable(tf.random_normal([2,3], stddev=2, mean=0, seed=1))
stdev 標準差; mean 均值; seed 隨機數(shù)種子;
tf.random_normal 表示 正態(tài)分布
tf.truncated_normal() 去掉過大偏離點的正態(tài)分布
tf.random_uniform() 平均分布
變量的初始化
init_op = tf.global_variables_initializer()sess.run(init_op)
tf.placeholder占位,在sese.run中用feed_dict喂數(shù)據(jù)
x = tf.placeholder(tf.float32, shape=(1,2))sess.run(y, feed_dict={x:[[0.5,0.6]]})x = tf.placeholder(tf.float32, shape=(None,2))sess.run(y, feed_dict={x:[[0.1,0.2], [0.3,0.4], [0.5,0.6]]})神經(jīng)網(wǎng)絡(luò)實現(xiàn)過程
準備數(shù)據(jù)集,提取特征,作為輸入喂給神經(jīng)網(wǎng)絡(luò)
搭建NN結(jié)構(gòu),從輸入到輸出(先搭建計算圖,再用會話執(zhí)行)前向傳播算法計算輸出
大量特征數(shù)據(jù)喂給NN,迭代優(yōu)化NN參數(shù),反向傳播算法優(yōu)化參數(shù)訓練模型
將訓練好的模型投入實際使用
兩層簡單神經(jīng)網(wǎng)絡(luò)示例
import tensorflow as tf
x = tf.placeholder(tf.float32, shape=(None,2))w1 = tf.Variable(tf.random_normal([2,3], stddev=1, seed=1))w2 = tf.Variable(tf.random_normal([3,1], stddev=1, seed=1))a = tf.matmul(x,w1)y = tf.matmul(a,w2)with tf.Session() as sess:
init_op = tf.global_variables_initializer()
sess.run(init_op)
print(sess.run(y, feed_dict={x:[[0.7,0.5], [0.2,0.3], [0.3,0.4], [0.4,0.5]]}))
print(sess.run(w1))
print(sess.run(w2))
