资源 | 数十种TensorFlow实现案例汇集:代码+笔记
选自 Github
机器之心编译
参与:吴攀、李亚洲
这是使用 TensorFlow 实现流行的机器学习算法的教程汇集。本汇集的目标是让读者可以轻松通过案例深入 TensorFlow。
这些案例适合那些想要清晰简明的 TensorFlow 实现案例的初学者。本教程还包含了笔记和带有注解的代码。
项目地址:https://github.com/aymericdamien/TensorFlow-Examples
教程索引
0 - 先决条件
机器学习入门:
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/0_Prerequisite/ml_introduction.ipynb
MNIST 数据集入门
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/0_Prerequisite/mnist_dataset_intro.ipynb
1 - 入门
Hello World:
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/1_Introduction/helloworld.ipynb
代码https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/1_Introduction/helloworld.py
基本操作:
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/1_Introduction/basic_operations.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/1_Introduction/basic_operations.py
2 - 基本模型
最近邻:
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/2_BasicModels/nearest_neighbor.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/nearest_neighbor.py
线性回归:
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/2_BasicModels/linear_regression.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/linear_regression.py
Logistic 回归:
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/2_BasicModels/logistic_regression.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/logistic_regression.py
3 - 神经网络
多层感知器:
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/multilayer_perceptron.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/multilayer_perceptron.py
卷积神经网络:
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/convolutional_network.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/convolutional_network.py
循环神经网络(LSTM):
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/recurrent_network.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/recurrent_network.py
双向循环神经网络(LSTM):
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/bidirectional_rnn.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/bidirectional_rnn.py
动态循环神经网络(LSTM)
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/dynamic_rnn.py
自编码器
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/autoencoder.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/autoencoder.py
4 - 实用技术
保存和恢复模型
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/save_restore_model.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/save_restore_model.py
图和损失可视化
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/tensorboard_basic.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/tensorboard_basic.py
Tensorboard——高级可视化
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/tensorboard_advanced.py
5 - 多 GPU
多 GPU 上的基本操作
笔记:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/5_MultiGPU/multigpu_basics.ipynb
代码:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/5_MultiGPU/multigpu_basics.py
数据集
一些案例需要 MNIST 数据集进行训练和测试。不要担心,运行这些案例时,该数据集会被自动下载下来(使用 input_data.py)。MNIST 是一个手写数字的数据库,查看这个笔记了解关于该数据集的描述:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/0_Prerequisite/mnist_dataset_intro.ipynb
官方网站:http://yann.lecun.com/exdb/mnist/
更多案例
接下来的示例来自 TFLearn(https://github.com/tflearn/tflearn),这是一个为 TensorFlow 提供了简化的接口的库。你可以看看,这里有很多示例和预构建的运算和层。
示例:https://github.com/tflearn/tflearn/tree/master/examples
预构建的运算和层:http://tflearn.org/doc_index/#api
教程
TFLearn 快速入门。通过一个具体的机器学习任务学习 TFLearn 基础。开发和训练一个深度神经网络分类器。
笔记:https://github.com/tflearn/tflearn/blob/master/tutorials/intro/quickstart.md
基础
线性回归,使用 TFLearn 实现线性回归:https://github.com/tflearn/tflearn/blob/master/examples/basics/linear_regression.py
逻辑运算符。使用 TFLearn 实现逻辑运算符:https://github.com/tflearn/tflearn/blob/master/examples/basics/logical.py
权重保持。保存和还原一个模型:https://github.com/tflearn/tflearn/blob/master/examples/basics/weights_persistence.py
微调。在一个新任务上微调一个预训练的模型:https://github.com/tflearn/tflearn/blob/master/examples/basics/finetuning.py
使用 HDF5。使用 HDF5 处理大型数据集:https://github.com/tflearn/tflearn/blob/master/examples/basics/use_hdf5.py
使用 DASK。使用 DASK 处理大型数据集:https://github.com/tflearn/tflearn/blob/master/examples/basics/use_dask.py
计算机视觉
多层感知器。一种用于 MNIST 分类任务的多层感知实现:https://github.com/tflearn/tflearn/blob/master/examples/images/dnn.py
卷积网络(MNIST)。用于分类 MNIST 数据集的一种卷积神经网络实现:https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_mnist.py
卷积网络(CIFAR-10)。用于分类 CIFAR-10 数据集的一种卷积神经网络实现:https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_cifar10.py
网络中的网络。用于分类 CIFAR-10 数据集的 Network in Network 实现:https://github.com/tflearn/tflearn/blob/master/examples/images/network_in_network.py
Alexnet。将 Alexnet 应用于 Oxford Flowers 17 分类任务:https://github.com/tflearn/tflearn/blob/master/examples/images/alexnet.py
VGGNet。将 VGGNet 应用于 Oxford Flowers 17 分类任务:https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network.py
VGGNet Finetuning (Fast Training)。使用一个预训练的 VGG 网络并将其约束到你自己的数据上,以便实现快速训练:https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network_finetuning.py
RNN Pixels。使用 RNN(在像素的序列上)分类图像:https://github.com/tflearn/tflearn/blob/master/examples/images/rnn_pixels.py
Highway Network。用于分类 MNIST 数据集的 Highway Network 实现:https://github.com/tflearn/tflearn/blob/master/examples/images/highway_dnn.py
Highway Convolutional Network。用于分类 MNIST 数据集的 Highway Convolutional Network 实现:https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_highway_mnist.py
Residual Network (MNIST) (https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_mnist.py).。应用于 MNIST 分类任务的一种瓶颈残差网络(bottleneck residual network):https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_mnist.py
Residual Network (CIFAR-10)。应用于 CIFAR-10 分类任务的一种残差网络:https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_cifar10.py
Google Inception(v3)。应用于 Oxford Flowers 17 分类任务的谷歌 Inception v3 网络:https://github.com/tflearn/tflearn/blob/master/examples/images/googlenet.py
自编码器。用于 MNIST 手写数字的自编码器:https://github.com/tflearn/tflearn/blob/master/examples/images/autoencoder.py
自然语言处理
循环神经网络(LSTM),应用 LSTM 到 IMDB 情感数据集分类任务:https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm.py
双向 RNN(LSTM),将一个双向 LSTM 应用到 IMDB 情感数据集分类任务:https://github.com/tflearn/tflearn/blob/master/examples/nlp/bidirectional_lstm.py
动态 RNN(LSTM),利用动态 LSTM 从 IMDB 数据集分类可变长度文本:https://github.com/tflearn/tflearn/blob/master/examples/nlp/dynamic_lstm.py
城市名称生成,使用 LSTM 网络生成新的美国城市名:https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm_generator_cityname.py
莎士比亚手稿生成,使用 LSTM 网络生成新的莎士比亚手稿:https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm_generator_shakespeare.py
Seq2seq,seq2seq 循环网络的教学示例:https://github.com/tflearn/tflearn/blob/master/examples/nlp/seq2seq_example.py
CNN Seq,应用一个 1-D 卷积网络从 IMDB 情感数据集中分类词序列:https://github.com/tflearn/tflearn/blob/master/examples/nlp/cnn_sentence_classification.py
强化学习
Atari Pacman 1-step Q-Learning,使用 1-step Q-learning 教一台机器玩 Atari 游戏:https://github.com/tflearn/tflearn/blob/master/examples/reinforcement_learning/atari_1step_qlearning.py
其他
Recommender-Wide&Deep Network,推荐系统中 wide & deep 网络的教学示例:https://github.com/tflearn/tflearn/blob/master/examples/others/recommender_wide_and_deep.py
Notebooks
Spiral Classification Problem,对斯坦福 CS231n spiral 分类难题的 TFLearn 实现:https://github.com/tflearn/tflearn/blob/master/examples/notebooks/spiral.ipynb
可延展的 TensorFlow
层,与 TensorFlow 一起使用 TFLearn 层:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/layers.py
训练器,使用 TFLearn 训练器类训练任何 TensorFlow 图:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/layers.py
Bulit-in Ops,连同 TensorFlow 使用 TFLearn built-in 操作:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/builtin_ops.py
Summaries,连同 TensorFlow 使用 TFLearn summarizers:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/summaries.py
Variables,连同 TensorFlow 使用 TFLearn Variables:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/variables.py
资源 | 数十种TensorFlow实现案例汇集:代码+笔记的更多相关文章
- 数十种TensorFlow实现案例汇集:代码+笔记(转)
转:https://www.jiqizhixin.com/articles/30dc6dd9-39cd-406b-9f9e-041f5cbf1d14 这是使用 TensorFlow 实现流行的机器学习 ...
- 数十种TensorFlow实现案例汇集:代码+笔记
这是使用 TensorFlow 实现流行的机器学习算法的教程汇集.本汇集的目标是让读者可以轻松通过案例深入 TensorFlow. 这些案例适合那些想要清晰简明的 TensorFlow 实现案例的初学 ...
- Scala进阶之路-统计商家id的标签数以及TopN示例案例分析
Scala进阶之路-统计商家id的标签数以及TopN示例案例分析 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.项目需求 将“temptags.txt”中的数据进行分析,统计出 ...
- http连接优化与浏览器允许的并发请求资源数相关资料(整理转载)
网页性能优化相关资料: https://developer.yahoo.com/performance/rules.html#page-nav 前端技术的逐渐成熟,还衍生了domain hash, c ...
- ntohs的一个简单实现(将网络流中用两个字节16进制表示的资源数(如DNS)和长度转换为整形)
我们知道在由于大端机和小端机导致网络字节序和主机序有可能是有差异的,我们可以使用系统的ntohs,ntohl,htons和htonl这些处理函数进行转换,下面是我写的一个关于ntohs在处理小端机字节 ...
- 【hadoop代码笔记】hadoop作业提交之汇总
一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...
- 【hadoop代码笔记】Mapreduce shuffle过程之Map输出过程
一.概要描述 shuffle是MapReduce的一个核心过程,因此没有在前面的MapReduce作业提交的过程中描述,而是单独拿出来比较详细的描述. 根据官方的流程图示如下: 本篇文章中只是想尝试从 ...
- 《SAS编程和数据挖掘商业案例》学习笔记# 19
继续<SAS编程与数据挖掘商业案例>学习笔记,本文側重数据处理实践.包含:HASH对象.自己定义format.以及功能强大的正則表達式 一:HASH对象 Hash对象又称散列表,是依据关键 ...
- 【代码笔记】Java连连看项目的实现(2)——JTable 、TableModel的使用
博客有时间就写写,所以一篇可能会拆成很多篇,写完后计划再合在一起. 首先肯定是要实现连连看的界面. 先准备连连看要的图片.. “LianLianKan”就是项目名称. 当然,如果小白看我的博客想学到什 ...
随机推荐
- atitit.微信项目开发效率慢的一些总结
atitit.微信项目开发效率慢的一些总结 #---理念问题..这个是最大的问题.. 要有专人提升开发效率才好.. #---没有一个好的开发方法体系.... ini deve 法. fell asd+ ...
- paip.前端加载时间分析之道优化最佳实践
paip.前端加载时间分析之道优化最佳实践 1.另存为 ,查看文件尺寸..和图片. 2.view the 另存为的htm静态的文件单个的加载,看时间...可以排除编程语言的问题and 数据库.. ## ...
- 更改Windows系统的密码之后,SQL Server 2008服务无法启动
问题:更改Windows操作系统的密码之后,SQL Server 2008服务无法启动. 原因:SQL Server服务需要使用操作系统的某个登录账户. 解决:需要在服务的属性窗口中修改账户密码,然后 ...
- Entity Framework一对多关系添加数据的两种方式
当使用Entity Framework添加一对多关系数据的时候,通常先添加一的数据,然后再添加多的数据.类似这样: //添加一的数据 var category = new Category{Name= ...
- JavaScript学习汇总
对于JavaScript,还是无法割舍,有心无力,时间总是匆匆,暂且都放在这里吧 javascript中this的使用 写的很不错的一偏文章,简单看了下,mark了吧 原文:http://davids ...
- jackson 注脚学习参考
(1)初级我们从几个简单的使用场景开始:重命名属性,忽略属性,以及修改属性所使用的类型.注意:下面的例子仅仅显示了成员属性(field properties),注解同样也可以用在成员方法(getter ...
- Android开发利器 - Charles + Genymotion 调试网络应用程序
Charles默认是不监听Genymotion模拟器的网络动态的. 需要进行以下设置: 1. 打开你的Genymotion模拟器 2. 设置 -> Wifi -> 长按你的当前的网络连接 ...
- mysql 关键字 字段 转义
insert into tb_gps(imei,lat,lon,speed,dir,alt,atom,`signal`,batt,intime) values('46345435435345','22 ...
- Git忽略配置文件gitignore
在git客户端用户工程根目录下,.git同级目录创建文件.gitignore,文件名为.gitignore.目的是为了忽略一些不需要提交的文件到git服务器 配置如下: bin target .set ...
- 正则指引-字符组demo
class Program { static void Main(string[] args) { string str = "b"; var result1 = Regex.Is ...