Alan Hou的个人博客

探秘最炙手可热的人工智能框架TensorFlow

探秘最炙手可热的人工智能框架TensorFlow

环境搭建可参考Django环境搭建及开发的环境搭建部分,也可参照TensorFlow官网

本文主要内容

TensorFlow的基础知识

TensorFlow的使用案例

TensorFlow的基础知识

TensorFlow经典的数据流图

图中的各个节点是操作(Operation),中间的线是张量(Tensor)

TensorFlow的Hello World

Tensor有以下几种:constant(常量), Variable(变量), placeholder(占位符),SparseTensor(稀疏张量)

TensorBoard

如以下是后面卷积神经网络示例的TensorBoard

Playground

TensorFlow的操作(Operations)

TensorFlow的使用案例

梯度下降解决线性回归



激活函数(Activation Function)



深度学习的三大模型:

CNN(Convolution Neural Network)卷积神经网络
RNN(Recurrent Neural Network)循环神经网络
DBN(Deep Belief Network)深度信念网络

实现CNN(Convolution Neural Network)卷积神经网络



训练结果如下

RNN-LSTM循环神经网络

RNN问题:梯度消失、梯度爆炸

LSTM: Long Short-Term Memory

扩展阅读:Understanding LSTM Networks

LSTM神经元的“三重门”机制

PTB数据集:

wget http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz

本例中使用data文件夹下的ptb.test.txt,ptb.train.txt,ptb.valid.txt三个文件

utils.py

network.py

train.py

test.py

在Mac上进行一次训练需耗时30多分钟,写这篇文章时训练仍在进行,以下是第二次训练完成后执行test.py的结果,可以看到精确度还是很低的:

True words (1st line) vs. predicted words (2nd line)

stock market is headed many traders were afraid to trust stock prices quoted on the big board <eos> the futures halt was even <unk> by big board floor traders <eos> it <unk> things up said

is market is n’t by of said <unk> to be <eos> prices <eos> at a dollar board <eos> the dollar index that a a in a board in in said the is a that a

Average accuracy: 0.236

 

退出移动版