0

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

Posted by Alan on May 20, 2018 in Coding |

TensorFlow详细架构

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

本文主要内容

TensorFlow的基础知识

  • TensorFlow经典的数据流图
  • TensorFlow的Hello World
  • TensorBoard
  • TensorFlow的操作(Operations)

TensorFlow的使用案例

  • 梯度下降解决线性回归
  • 激活函数(Activation Function)
  • 实现CNN(Convolution Neural Network)卷积神经网络
  • RNN-LSTM循环神经网络

TensorFlow的基础知识

TensorFlow经典的数据流图

TensorFlow经典的Flowing Gif

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

TensorFlow的Hello World

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

TensorBoard

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

Tensorboard

Playground

TensorFlow的操作(Operations)

Tensorflow的操作(Operations)

TensorFlow的使用案例

梯度下降解决线性回归

梯度下降解决线性回归

激活函数(Activation Function)

激活函数(Activation Function)

深度学习的三大模型:

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

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

实现CNN卷积神经网络

训练结果如下

RNN-LSTM循环神经网络

神经网络示例

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

LSTM: Long Short-Term Memory

扩展阅读:Understanding LSTM Networks

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

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

PTB数据集:

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

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

LSTM训练流程

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

 

Tags: , , , ,

Leave a Reply

Copyright © 2012-2018 记录点滴生活 | Alan Hou的个人博客 All rights reserved.