This tutorial was designed for easily diving into TensorFlow, through examples. For readability, it includes both notebooks and source codes with explanation, for both TF v1 & v2.
本教程旨在通过示例轻松深入学习TensorFlow。为了便于阅读,教程中包括了Jupyter notebook和源代码,并附有对TF v1和v2的解释。
It is suitable for beginners who want to find clear and concise examples about TensorFlow. Besides the traditional 'raw' TensorFlow implementations, you can also find the latest TensorFlow API practices (such as layers
, estimator
, dataset
, ...).
这适合于想要找到关于TensorFlow清晰简洁示例的初学者。除了传统的“原始”TensorFlow实现,你还可以找到最新的TensorFlow API实践(例如layers
、estimator
、dataset
等)。
Update (05/16/2020): Moving all default examples to TF2. For TF v1 examples: check here.
更新(2020年5月16日): 将所有默认示例迁移到TF2。有关TF v1示例,请点击此处。
译者注 :这个项目是基于开源项目TensorFlow Examples制作的翻译为中文的版本,翻译可能不准确。译者不会删去原文,方便读者查阅原文进行比对。有时译者会插入这样的译者注,表达一些个人观点,如有错误还请指出。
-
Hello World (notebook). Very simple example to learn how to print "hello world" using TensorFlow 2.0+.
- Hello World (notebook). 通过简单的例子去学习如何基于TensorFlow 2.0+ 打印 “hello world” 。
-
Basic Operations (notebook). A simple example that cover TensorFlow 2.0+ basic operations.
- 基本操作(notebook)。一个简单的例子,涵盖了 TensorFlow 2.0+ 的基本操作。
-
Linear Regression (notebook). Implement a Linear Regression with TensorFlow 2.0+.
- 线性回归(notebook)。使用 TensorFlow 2.0+ 实现线性回归。
-
Logistic Regression (notebook). Implement a Logistic Regression with TensorFlow 2.0+.
- 逻辑回归(notebook)。使用 TensorFlow 2.0+ 实现逻辑回归。
-
Word2Vec (Word Embedding) (notebook). Build a Word Embedding Model (Word2Vec) from Wikipedia data, with TensorFlow 2.0+.
- Word2Vec(词嵌入、word to vector)(notebook)。使用 TensorFlow 2.0+ 从维基百科数据构建一个词嵌入模型(Word2Vec)。
-
GBDT (Gradient Boosted Decision Trees) (notebooks). Implement a Gradient Boosted Decision Trees with TensorFlow 2.0+ to predict house value using Boston Housing dataset.
- GBDT(梯度提升决策树)(notebooks)。使用 TensorFlow 2.0+ 实现梯度提升决策树,使用波士顿房价数据集进行房屋价值预测。
译者注 : 上面这两篇Word2Vec和GBDT的与目前需要的知识相关性不大, 且文件均存在较困难的Python包的版本问题,暂时不翻译。
- Simple Neural Network (notebook). Use TensorFlow 2.0 'layers' and 'model' API to build a simple neural network to classify MNIST digits dataset.
- 简单的神经网络 (notebook). 使用 TensorFlow 2.0 'layers' 和 'model' API 构建一个简单的神经网络,用于分类 MNIST 数字数据集。
- Simple Neural Network (low-level) (notebook). Raw implementation of a simple neural network to classify MNIST digits dataset.
- 简单的神经网络(低级)(notebook)。对 MNIST 数字数据集进行分类的简单神经网络的原始实现。(这个例子看起来和上一个例子相差不大、但是它使用了一种更加原始的方法,这里译者暂不翻译,请阅读上一条)
- Convolutional Neural Network (notebook). Use TensorFlow 2.0+ 'layers' and 'model' API to build a convolutional neural network to classify MNIST digits dataset.
- 卷积神经网络 。(notebook) 使用 TensorFlow 2.0+ 'layers' 和 'model' API 构建卷积神经网络,用于分类 MNIST 数字数据集。
- Convolutional Neural Network (low-level) (notebook). Raw implementation of a convolutional neural network to classify MNIST digits dataset.
- 卷积神经网络(低级) 。(notebook) 使用更原始的方式实现CNN,用于分类MNIST数据集。(这个例子与上一个例子相似,但是这个例子使用了更原始的方法,这里译者暂不翻译,请阅读上一条)
- Recurrent Neural Network (LSTM) (notebook). Build a recurrent neural network (LSTM) to classify MNIST digits dataset, using TensorFlow 2.0 'layers' and 'model' API.
- Bi-directional Recurrent Neural Network (LSTM) (notebook). Build a bi-directional recurrent neural network (LSTM) to classify MNIST digits dataset, using TensorFlow 2.0+ 'layers' and 'model' API.
- Dynamic Recurrent Neural Network (LSTM) (notebook). Build a recurrent neural network (LSTM) that performs dynamic calculation to classify sequences of variable length, using TensorFlow 2.0+ 'layers' and 'model' API.
译者注 :上面剩下的几篇想先忽略、这几篇的内容与目前需要的知识相关性不大。接下来会翻译Utility部分和Data Management部分的内容。
- Auto-Encoder (notebook). Build an auto-encoder to encode an image to a lower dimension and re-construct it.
- DCGAN (Deep Convolutional Generative Adversarial Networks) (notebook). Build a Deep Convolutional Generative Adversarial Network (DCGAN) to generate images from noise.
- Save and Restore a model (notebook). Save and Restore a model with TensorFlow 2.0+.
- 保存和读取模型 (notebook). 用 TensorFlow 2.0+ 保存和读取模型。
- Build Custom Layers & Modules (notebook). Learn how to build your own layers / modules and integrate them into TensorFlow 2.0+ Models.
- 此篇翻译暂时推迟
- Tensorboard (notebook). Track and visualize neural network computation graph, metrics, weights and more using TensorFlow 2.0+ tensorboard.
- Load and Parse data (notebook). Build efficient data pipeline with TensorFlow 2.0 (Numpy arrays, Images, CSV files, custom data, ...).
- 加载和解析数据 (notebook). 使用 TensorFlow 2.0创建高效的数据管道,如Numpy 数组、图像、CSV 文件、自定义数据等。
- Build and Load TFRecords (notebook). Convert data into TFRecords format, and load them with TensorFlow 2.0+.
- 构造和加载TFRecords (notebook). 用TensorFlow 2.0+ 将数据转换为TFRecords格式,并加载它们。
- 译者注 :这篇内容是关于TFRecords的,TFRecords是一种二进制文件格式,用于存储序列化的数据,这可以加速数据读取。如果目前的工作性能瓶颈并未出现在文件读取上,那么可以不用TFRecords。这里译者暂时不翻。
- Image Transformation (i.e. Image Augmentation) (notebook). Apply various image augmentation techniques with TensorFlow 2.0+, to generate distorted images for training.
- 图像变换 (即 图像增强) (notebook). 使用 TensorFlow 2.0+ 应用各种图像增强技术,生成用于训练的扭曲图像。
- Multi-GPU Training (notebook). Train a convolutional neural network with multiple GPUs on CIFAR-10 dataset.
The tutorial index for TF v1 is available here: TensorFlow v1.15 Examples. Or see below for a list of the examples.
Some examples require MNIST dataset for training and testing. Don't worry, this dataset will automatically be downloaded when running examples. MNIST is a database of handwritten digits, for a quick description of that dataset, you can check this notebook.
Official Website: http://yann.lecun.com/exdb/mnist/.
To download all the examples, simply clone this repository:
git clone https://github.com/aymericdamien/TensorFlow-Examples
To run them, you also need the latest version of TensorFlow. To install it:
pip install tensorflow
or (with GPU support):
pip install tensorflow_gpu
For more details about TensorFlow installation, you can check TensorFlow Installation Guide
The tutorial index for TF v1 is available here: TensorFlow v1.15 Examples.
- Hello World (notebook) (code). Very simple example to learn how to print "hello world" using TensorFlow.
- Basic Operations (notebook) (code). A simple example that cover TensorFlow basic operations.
- TensorFlow Eager API basics (notebook) (code). Get started with TensorFlow's Eager API.
- Linear Regression (notebook) (code). Implement a Linear Regression with TensorFlow.
- Linear Regression (eager api) (notebook) (code). Implement a Linear Regression using TensorFlow's Eager API.
- Logistic Regression (notebook) (code). Implement a Logistic Regression with TensorFlow.
- Logistic Regression (eager api) (notebook) (code). Implement a Logistic Regression using TensorFlow's Eager API.
- Nearest Neighbor (notebook) (code). Implement Nearest Neighbor algorithm with TensorFlow.
- K-Means (notebook) (code). Build a K-Means classifier with TensorFlow.
- Random Forest (notebook) (code). Build a Random Forest classifier with TensorFlow.
- Gradient Boosted Decision Tree (GBDT) (notebook) (code). Build a Gradient Boosted Decision Tree (GBDT) with TensorFlow.
- Word2Vec (Word Embedding) (notebook) (code). Build a Word Embedding Model (Word2Vec) from Wikipedia data, with TensorFlow.
- Simple Neural Network (notebook) (code). Build a simple neural network (a.k.a Multi-layer Perceptron) to classify MNIST digits dataset. Raw TensorFlow implementation.
- Simple Neural Network (tf.layers/estimator api) (notebook) (code). Use TensorFlow 'layers' and 'estimator' API to build a simple neural network (a.k.a Multi-layer Perceptron) to classify MNIST digits dataset.
- Simple Neural Network (eager api) (notebook) (code). Use TensorFlow Eager API to build a simple neural network (a.k.a Multi-layer Perceptron) to classify MNIST digits dataset.
- Convolutional Neural Network (notebook) (code). Build a convolutional neural network to classify MNIST digits dataset. Raw TensorFlow implementation.
- Convolutional Neural Network (tf.layers/estimator api) (notebook) (code). Use TensorFlow 'layers' and 'estimator' API to build a convolutional neural network to classify MNIST digits dataset.
- Recurrent Neural Network (LSTM) (notebook) (code). Build a recurrent neural network (LSTM) to classify MNIST digits dataset.
- Bi-directional Recurrent Neural Network (LSTM) (notebook) (code). Build a bi-directional recurrent neural network (LSTM) to classify MNIST digits dataset.
- Dynamic Recurrent Neural Network (LSTM) (notebook) (code). Build a recurrent neural network (LSTM) that performs dynamic calculation to classify sequences of different length.
- Auto-Encoder (notebook) (code). Build an auto-encoder to encode an image to a lower dimension and re-construct it.
- Variational Auto-Encoder (notebook) (code). Build a variational auto-encoder (VAE), to encode and generate images from noise.
- GAN (Generative Adversarial Networks) (notebook) (code). Build a Generative Adversarial Network (GAN) to generate images from noise.
- DCGAN (Deep Convolutional Generative Adversarial Networks) (notebook) (code). Build a Deep Convolutional Generative Adversarial Network (DCGAN) to generate images from noise.
- Save and Restore a model (notebook) (code). Save and Restore a model with TensorFlow.
- Tensorboard - Graph and loss visualization (notebook) (code). Use Tensorboard to visualize the computation Graph and plot the loss.
- Tensorboard - Advanced visualization (notebook) (code). Going deeper into Tensorboard; visualize the variables, gradients, and more...
- Build an image dataset (notebook) (code). Build your own images dataset with TensorFlow data queues, from image folders or a dataset file.
- TensorFlow Dataset API (notebook) (code). Introducing TensorFlow Dataset API for optimizing the input data pipeline.
- Load and Parse data (notebook). Build efficient data pipeline (Numpy arrays, Images, CSV files, custom data, ...).
- Build and Load TFRecords (notebook). Convert data into TFRecords format, and load them.
- Image Transformation (i.e. Image Augmentation) (notebook). Apply various image augmentation techniques, to generate distorted images for training.
- Basic Operations on multi-GPU (notebook) (code). A simple example to introduce multi-GPU in TensorFlow.
- Train a Neural Network on multi-GPU (notebook) (code). A clear and simple TensorFlow implementation to train a convolutional neural network on multiple GPUs.
The following examples are coming from TFLearn, a library that provides a simplified interface for TensorFlow. You can have a look, there are many examples and pre-built operations and layers.
- TFLearn Quickstart. Learn the basics of TFLearn through a concrete machine learning task. Build and train a deep neural network classifier.
- TFLearn Examples. A large collection of examples using TFLearn.