All Projects → yongyehuang → Tensorflow Tutorial

yongyehuang / Tensorflow Tutorial

Some interesting TensorFlow tutorials for beginners.

Projects that are alternatives of or similar to Tensorflow Tutorial

Keras basic
keras를 이용한 딥러닝 기초 학습
Stars: ✭ 39 (-95.63%)
Mutual labels:  jupyter-notebook, cnn, lstm
Deeplearning tutorials
The deeplearning algorithms implemented by tensorflow
Stars: ✭ 1,580 (+76.93%)
Mutual labels:  jupyter-notebook, cnn, lstm
End To End Sequence Labeling Via Bi Directional Lstm Cnns Crf Tutorial
Tutorial for End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF
Stars: ✭ 87 (-90.26%)
Mutual labels:  jupyter-notebook, cnn, lstm
Video Classification
Tutorial for video classification/ action recognition using 3D CNN/ CNN+RNN on UCF101
Stars: ✭ 543 (-39.19%)
Mutual labels:  jupyter-notebook, cnn, lstm
Natural Language Processing With Tensorflow
Natural Language Processing with TensorFlow, published by Packt
Stars: ✭ 222 (-75.14%)
Mutual labels:  jupyter-notebook, cnn, lstm
Neural Networks
All about Neural Networks!
Stars: ✭ 34 (-96.19%)
Mutual labels:  jupyter-notebook, cnn, lstm
Pytorch Learners Tutorial
PyTorch tutorial for learners
Stars: ✭ 97 (-89.14%)
Mutual labels:  jupyter-notebook, cnn, lstm
Qa Rankit
QA - Answer Selection (Rank candidate answers for a given question)
Stars: ✭ 30 (-96.64%)
Mutual labels:  jupyter-notebook, cnn, lstm
Screenshot To Code
A neural network that transforms a design mock-up into a static website.
Stars: ✭ 13,561 (+1418.59%)
Mutual labels:  jupyter-notebook, cnn, lstm
Lidc nodule detection
lidc nodule detection with CNN and LSTM network
Stars: ✭ 187 (-79.06%)
Mutual labels:  jupyter-notebook, cnn, lstm
Neural Image Captioning
Implementation of Neural Image Captioning model using Keras with Theano backend
Stars: ✭ 12 (-98.66%)
Mutual labels:  jupyter-notebook, cnn, lstm
Image Captioning
Image Captioning using InceptionV3 and beam search
Stars: ✭ 290 (-67.53%)
Mutual labels:  jupyter-notebook, cnn, lstm
Pytorch Pos Tagging
A tutorial on how to implement models for part-of-speech tagging using PyTorch and TorchText.
Stars: ✭ 96 (-89.25%)
Mutual labels:  jupyter-notebook, cnn, lstm
Deep Learning With Python
Example projects I completed to understand Deep Learning techniques with Tensorflow. Please note that I do no longer maintain this repository.
Stars: ✭ 134 (-84.99%)
Mutual labels:  jupyter-notebook, lstm, tensorflow-tutorials
Pytorch Sentiment Analysis
Tutorials on getting started with PyTorch and TorchText for sentiment analysis.
Stars: ✭ 3,209 (+259.35%)
Mutual labels:  jupyter-notebook, cnn, lstm
Cryptocurrencyprediction
Predict Cryptocurrency Price with Deep Learning
Stars: ✭ 453 (-49.27%)
Mutual labels:  jupyter-notebook, cnn, lstm
Deeplearning
深度学习入门教程, 优秀文章, Deep Learning Tutorial
Stars: ✭ 6,783 (+659.57%)
Mutual labels:  jupyter-notebook, cnn
Attention Networks For Classification
Hierarchical Attention Networks for Document Classification in PyTorch
Stars: ✭ 540 (-39.53%)
Mutual labels:  jupyter-notebook, lstm
Telemanom
A framework for using LSTMs to detect anomalies in multivariate time series data. Includes spacecraft anomaly data and experiments from the Mars Science Laboratory and SMAP missions.
Stars: ✭ 589 (-34.04%)
Mutual labels:  jupyter-notebook, lstm
Textclassificationbenchmark
A Benchmark of Text Classification in PyTorch
Stars: ✭ 534 (-40.2%)
Mutual labels:  cnn, lstm

Tensorflow-Tutorial

2018-04 更新说明

时间过去一年,TensorFlow 已经从 1.0 版本更新到了 1.8 版本,而且最近更新的非常频繁。最烦的就是每次更新很多 API 都改了,一些老版本的代码就跑不通了。因为本项目关注的人越来越多了,所以自己也感觉到非常有必要更新并更正一些之前的错误,否则误人子弟就不好了。这里不少内容可以直接在官方的教程中找到,官方文档也在不断完善中,我也是把里边的例子跑一下,加深理解而已,更多的还是要自己在具体任务中去搭模型,训模型才能很好地掌握。

这一次更新主要内容如下:

  • 使用较新版本的 tfmaster
  • 所有的代码改成 python3.5
  • 重新整理了基础用例
  • 添加实战例子

因为工作和学习比较忙,所以这些内容也没办法一下子完成。和之前的版本不同,之前我是作为一个入门菜鸟一遍学一边做笔记。虽然现在依然还是理解得不够,但是比之前掌握的知识应该多了不少,希望能够整理成一个更好的教程。

之前的代码我放在了另外一个分支上: https://github.com/yongyehuang/Tensorflow-Tutorial/tree/1.2.1

如果有什么问题或者建议,欢迎开issue或者邮件与我联系:[email protected]

运行环境

  • python 3.5
  • tensorflow master (gpu version)

文件结构

|- Tensorflow-Tutorial
|  |- example-notebook     # 入门教程 notebook 版
|  |- example-python      # 入门教程 .py 版
|  |- utils                # 一些工具函数(logging, tf.flags)
|  |- models               # 一些实战的例子(BN, GAN, 序列标注,seq2seq 等,持续更新)
|  |- data               # 数据
|  |- doc             # 相关文档

1.入门例子

T_01.TensorFlow 的基本用法

介绍 TensorFlow 的变量、常量和基本操作,最后介绍了一个非常简单的回归拟合例子。

T_02.实现一个两层的全连接网络对 MNIST 进行分类

T_03.TensorFlow 变量命名管理机制

  • notebook1 介绍 tf.Variable() 和 tf.get_variable() 创建变量的区别;介绍如何使用 tf.name_scope() 和 tf.variable_scope() 管理命名空间。

  • notebook2 除了使用变量命名来管理变量之外,还经常用到 collection 的方式来聚合一些变量或者操作。

T_04.实现一个两层的卷积神经网络(CNN)对 MNIST 进行分类

构建一个非常简单的 CNN 网络,同时输出中间各个核的可视化来理解 CNN 的原理。

第一层卷积核可视化

在上一个例子的基础上,加入 BN 层。在 CNN 中,使用 BN 层可以加速收敛速度,同时也能够减小初始化方式的影响。在使用 BN 层的时候要注意训练时用的是 mini-batch 的均值方差,测试时用的是指数平均的均值方差。所以在训练的过程中,一定要记得更新并保存均值方差。

在这个小网络中:迭代 10000 步,batch_size=100,大概耗时 45s;添加了 BN 层之后,迭代同样的次数,大概耗时 90s.

T_05.实现多层的 LSTM 和 GRU 网络对 MNIST 进行分类

字符 8 lstm 对字符 8 的识别过程

T_06.tensorboard 的简单用法

简单的 tensorboard 可视化

T_07.使用 tf.train.Saver() 来保存模型

T_08.【迁移学习】往一个已经保存好的 模型添加新的变量

T_09.使用 tfrecord 打包不定长的序列数据

T_10.使用 tf.data.Dataset 和 tfrecord 给 numpy 数据构建数据集

下面是对 MNIST 数据训练集 55000 个样本 读取的一个速度比较,统一 batch_size=128,主要比较 one-shotinitializable 两种迭代方式:

iter_mode buffer_size 100 batch(s)
one-shot 2000 125
one-shot 5000 149
initializable 2000 0.7
initializable 5000 0.7

可以看到,使用 initializable 方式的速度明显要快很多。因为使用 one-shot 方式会把整个矩阵放在图中,计算非常非常慢。

T_11.使用 tf.data.Dataset 和 tfrecord 给 图片数据 构建数据集

对于 png 数据的读取,我尝试了 3 组不同的方式: one-shot 方式, tf 的队列方式(queue), tfrecord 方式. 同样是在机械硬盘上操作, 结果是 tfrecord 方式明显要快一些。(batch_size=128,图片大小为256*256,机械硬盘)

iter_mode buffer_size 100 batch(s)
one-shot 2000 75
one-shot 5000 86
tf.queue 2000 11
tf.queue 5000 11
tfrecord 2000 5.3
tfrecord 5000 5.3

如果是在 SSD 上面的话,tf 的队列方式应该也是比较快的.打包成 tfrecord 格式只是减少了小文件的读取,其实现也是使用队列的。

T_12.TensorFlow 高级API tf.layers 的使用

使用 TensorFlow 原生的 API 能够帮助自己很好的理解网络的细节,但是往往比较低效。 tf.layers 和 tf.keras 一样,是一个封装得比较好的一个高级库,接口用着挺方便的。所以在开发的时候,可以使用高级的接口能够有效的提高工作效率。

2.TensorFlow 实战(持续更新)

下面的每个例子都是相互独立的,每个文件夹下面的代码都是可以单独运行的,不依赖于其他文件夹。

m01_batch_normalization: Batch Normalization 的使用

参考:tensorflow中batch normalization的用法

m02_dcgan: 使用 DCGAN 生成二次元头像

参考:

这里的 notebook 和 .py 文件的内容是一样的。本例子和下面的 GAN 模型用的数据集也是用了GAN学习指南:从原理入门到制作生成Demo 的二次元头像,感觉这里例子比较有意思。如果想使用其他数据集的话,只需要把数据集换一下就行了。

下载链接: https://pan.baidu.com/s/1HBJpfkIFaGh0s2nfNXJsrA 密码: x39r

下载后把所有的图片解压到一个文件夹中,比如本例中是: data_path = '../../data/anime/'

运行: python dcgan.py

m03_wgan: 使用 WGAN 生成二次元头像

这里的生成器和判别器我只实现了 DCGAN,没有实现 MLP. 如果想实现的话可以参考下面的两个例子。 参考:

原版的 wgan: python wgan.py

改进的 wgan-gp: python wgan_gp.py

m04_pix2pix: image-to-image

代码来自:affinelayer/pix2pix-tensorflow

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].