Skip to content

Commit d96e263

Browse files
committed
update docs for examples
1 parent cf6b095 commit d96e263

File tree

4 files changed

+47
-48
lines changed

4 files changed

+47
-48
lines changed

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -137,27 +137,26 @@ We provide many helper functions (like `fit()` , `test()`) that is similar to Ke
137137
Examples can be found [in this repository](https://github.com/zsdonghao/tensorlayer/tree/master/example) and [TensorLayer Topic](https://github.com/search?q=topic%3Atensorlayer&type=Repositories).
138138

139139
## Basics
140-
- Multi-layer perceptron (MNIST). A multi-layer perceptron implementation for MNIST classification task, see ``tutorial_mnist_simple.py``.
140+
- Multi-layer perceptron (MNIST). A multi-layer perceptron implementation for MNIST classification task, see [tutorial\_mnist\_simple.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist_simple.py).
141141

142142
## Computer Vision
143-
- Denoising Autoencoder (MNIST). A multi-layer perceptron implementation for MNIST classification task, see ``tutorial_mnist.py``.
144-
- Stacked Denoising Autoencoder and Fine-Tuning (MNIST). A multi-layer perceptron implementation for MNIST classification task, see ``tutorial_mnist.py``.
145-
- Convolutional Network (MNIST). A Convolutional neural network implementation for classifying MNIST dataset, see ``tutorial_mnist.py``.
146-
- Convolutional Network (CIFAR-10). A Convolutional neural network implementation for classifying CIFAR-10 dataset, see ``tutorial_cifar10.py`` and ``tutorial_cifar10_tfrecord.py``.
147-
- VGG 16 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see ``tutorial_vgg16.py``.
148-
- VGG 19 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see ``tutorial_vgg19.py``.
149-
- InceptionV3 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see ``tutorial_inceptionV3_tfslim.py``.
143+
- Denoising Autoencoder (MNIST). A multi-layer perceptron implementation for MNIST classification task, see [tutorial_mnist.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist.py).
144+
- Stacked Denoising Autoencoder and Fine-Tuning (MNIST). A multi-layer perceptron implementation for MNIST classification task, see [tutorial_mnist.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist.py).
145+
- Convolutional Network (MNIST). A Convolutional neural network implementation for classifying MNIST dataset, see [tutorial_mnist.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist.py).
146+
- Convolutional Network (CIFAR-10). A Convolutional neural network implementation for classifying CIFAR-10 dataset, see [tutorial\_cifar10.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_cifar10.py) and [tutorial\_cifar10_tfrecord.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_cifar10_tfrecord.py).
147+
- VGG 16 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see [tutorial_vgg16.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_vgg16.py).
148+
- VGG 19 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see [tutorial_vgg19.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_vgg19.py).
149+
- InceptionV3 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see [tutorial\_inceptionV3_tfslim.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_inceptionV3_tfslim.py).
150150
- Wide ResNet (CIFAR) by [ritchieng](https://github.com/ritchieng/wideresnet-tensorlayer).
151151
- More CNN implementations of [TF-Slim](https://github.com/tensorflow/models/tree/master/slim#pre-trained-models) can be connected to TensorLayer via SlimNetsLayer.
152152
- [Spatial Transformer Networks](https://arxiv.org/abs/1506.02025) by [zsdonghao](https://github.com/zsdonghao/Spatial-Transformer-Nets).
153153
- [U-Net for brain tumor segmentation](https://github.com/zsdonghao/u-net-brain-tumor) by [zsdonghao](https://github.com/zsdonghao/u-net-brain-tumor).
154154

155155
## Natural Language Processing
156-
- Recurrent Neural Network (LSTM). Apply multiple LSTM to PTB dataset for language modeling, see ``tutorial_ptb_lstm_state_is_tuple.py``.
157-
- Word Embedding - Word2vec. Train a word embedding matrix, see ``tutorial_word2vec_basic.py``.
158-
- Restore Embedding matrix. Restore a pre-train embedding matrix, see ``tutorial_generate_text.py``.
159-
- Text Generation. Generates new text scripts, using LSTM network, see ``tutorial_generate_text.py``.
160-
- Machine Translation (WMT). Translate English to French. Apply Attention mechanism and Seq2seq to WMT English-to-French translation data, see ``tutorial_translate.py``.
156+
- Recurrent Neural Network (LSTM). Apply multiple LSTM to PTB dataset for language modeling, see [tutorial_ptb_lstm.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_ptb_lstm.py) and [tutorial\_ptb\_lstm\_state\_is_tuple.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_ptb_lstm_state_is_tuple.py).
157+
- Word Embedding - Word2vec. Train a word embedding matrix, see [tutorial\_word2vec_basic.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial\_word2vec_basic.py).
158+
- Restore Embedding matrix. Restore a pre-train embedding matrix, see [tutorial\_generate_text.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_generate_text.py).
159+
- Text Generation. Generates new text scripts, using LSTM network, see [tutorial\_generate_text.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_generate_text.py).
161160

162161
## Adversarial Learning
163162
- DCGAN - Generating images by [Deep Convolutional Generative Adversarial Networks](http://arxiv.org/abs/1511.06434) by [zsdonghao](https://github.com/zsdonghao/dcgan).
@@ -166,9 +165,9 @@ Examples can be found [in this repository](https://github.com/zsdonghao/tensorla
166165
- [Super Resolution GAN](https://arxiv.org/abs/1609.04802) by [zsdonghao](https://github.com/zsdonghao/SRGAN).
167166

168167
## Reinforcement Learning
169-
- Policy Gradient / Network - Pong Game. Teach a machine to play Pong games, see ``tutorial_atari_pong.py``.
170-
- Q-Network - Frozen lake, see ``tutorial_frozenlake_q_network.py``.
171-
- Q-Table learning algorithm - Frozen lake, see ``tutorial_frozenlake_q_table.py``.
168+
- Policy Gradient / Network - Pong. Atari Ping Pong, see [tutorial\_atari_pong.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_atari_pong.py).
169+
- Deep Q-Network - Frozen lake, see [tutorial\_frozenlake_dqn.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_frozenlake_dqn.py).
170+
- Q-Table learning algorithm - Frozen lake, see [tutorial\_frozenlake\_q_table.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_frozenlake_q_table.py).
172171
- Asynchronous Deep Reinforcement Learning - Pong Game by [nebulaV](https://github.com/akaraspt/tl_paper).
173172

174173

@@ -177,11 +176,10 @@ Examples can be found [in this repository](https://github.com/zsdonghao/tensorla
177176
- A simple web service - [TensorFlask](https://github.com/JoelKronander/TensorFlask) by [JoelKronander](https://github.com/JoelKronander).
178177

179178
## Special Examples
180-
- Merge TF-Slim into TensorLayer. ``tutorial_inceptionV3_tfslim.py``.
181-
- Merge Keras into TensorLayer. ``tutorial_keras.py``.
182-
- MultiplexerLayer. ``tutorial_mnist_multiplexer.py``.
183-
- Data augmentation with TFRecord. Effective way to load and pre-process data, see ``tutorial_tfrecord*.py`` and ``tutorial_cifar10_tfrecord.py``.
184-
- Data augmentation with TensorLayer, see ``tutorial_image_preprocess.py``.
179+
- Merge TF-Slim into TensorLayer. [tutorial\_inceptionV3_tfslim.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_inceptionV3_tfslim.py).
180+
- Merge Keras into TensorLayer. [tutorial_keras.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_keras.py).
181+
- Data augmentation with TFRecord. Effective way to load and pre-process data, see [tutorial_tfrecord*.py](https://github.com/zsdonghao/tensorlayer/tree/master/example) and [tutorial\_cifar10_tfrecord.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_cifar10_tfrecord.py).
182+
- Data augmentation with TensorLayer, see [tutorial\_image_preprocess.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_image_preprocess.py).
185183
- TensorDB by [fangde](https://github.com/fangde) see [here](https://github.com/akaraspt/tl_paper).
186184

187185
## Notes

docs/user/example.rst

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ Example
88
Basics
99
============
1010

11-
- Multi-layer perceptron (MNIST). A multi-layer perceptron implementation for MNIST classification task, see ``tutorial_mnist_simple.py`` on `GitHub`_.
11+
- Multi-layer perceptron (MNIST). A multi-layer perceptron implementation for MNIST classification task, see `tutorial_mnist_simple.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist_simple.py>`_.
1212

1313
Computer Vision
1414
==================
1515

16-
- Denoising Autoencoder (MNIST). A multi-layer perceptron implementation for MNIST classification task, see ``tutorial_mnist.py`` on `GitHub`_.
17-
- Stacked Denoising Autoencoder and Fine-Tuning (MNIST). A multi-layer perceptron implementation for MNIST classification task, see ``tutorial_mnist.py`` on `GitHub`_.
18-
- Convolutional Network (MNIST). A Convolutional neural network implementation for classifying MNIST dataset, see ``tutorial_mnist.py`` on `GitHub`_.
19-
- Convolutional Network (CIFAR-10). A Convolutional neural network implementation for classifying CIFAR-10 dataset, see ``tutorial_cifar10.py`` and ``tutorial_cifar10_tfrecord.py``on `GitHub`_.
20-
- VGG 16 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see ``tutorial_vgg16.py`` on `GitHub`_.
21-
- VGG 19 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see ``tutorial_vgg19.py`` on `GitHub`_.
22-
- InceptionV3 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see ``tutorial_inceptionV3_tfslim.py`` on `GitHub`_.
16+
- Denoising Autoencoder (MNIST). A multi-layer perceptron implementation for MNIST classification task, see `tutorial_mnist.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist.py>`_.
17+
- Stacked Denoising Autoencoder and Fine-Tuning (MNIST). A multi-layer perceptron implementation for MNIST classification task, see `tutorial_mnist.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist.py>`_.
18+
- Convolutional Network (MNIST). A Convolutional neural network implementation for classifying MNIST dataset, see `tutorial_mnist.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist.py>`_.
19+
- Convolutional Network (CIFAR-10). A Convolutional neural network implementation for classifying CIFAR-10 dataset, see `tutorial_cifar10.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_cifar10.py>`_ and `tutorial_cifar10_tfrecord.py <tutorial\_cifar10_tfrecord.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_cifar10_tfrecord.py>`_.
20+
- VGG 16 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see `tutorial_vgg16.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_vgg16.py>`_.
21+
- VGG 19 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see `tutorial_vgg19.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_vgg19.py>`_.
22+
- InceptionV3 (ImageNet). A Convolutional neural network implementation for classifying ImageNet dataset, see `tutorial_inceptionV3_tfslim.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_inceptionV3_tfslim.py>`_.
2323
- Wide ResNet (CIFAR) by `ritchieng <https://github.com/ritchieng/wideresnet-tensorlayer>`_.
2424
- More CNN implementations of `TF-Slim <https://github.com/tensorflow/models/tree/master/slim#pre-trained-models>`_ can be connected to TensorLayer via SlimNetsLayer.
2525
- `Spatial Transformer Networks <https://arxiv.org/abs/1506.02025>`_ by `zsdonghao <https://github.com/zsdonghao/Spatial-Transformer-Nets>`_.
@@ -29,11 +29,10 @@ Computer Vision
2929
Natural Language Processing
3030
==============================
3131

32-
- Recurrent Neural Network (LSTM). Apply multiple LSTM to PTB dataset for language modeling, see ``tutorial_ptb_lstm_state_is_tuple.py`` on `GitHub`_.
33-
- Word Embedding - Word2vec. Train a word embedding matrix, see ``tutorial_word2vec_basic.py`` on `GitHub`_.
34-
- Restore Embedding matrix. Restore a pre-train embedding matrix, see ``tutorial_generate_text.py`` on `GitHub`_.
35-
- Text Generation. Generates new text scripts, using LSTM network, see ``tutorial_generate_text.py`` on `GitHub`_.
36-
- Machine Translation (WMT). Translate English to French. Apply Attention mechanism and Seq2seq to WMT English-to-French translation data, see ``tutorial_translate.py`` on `GitHub`_.
32+
- Recurrent Neural Network (LSTM). Apply multiple LSTM to PTB dataset for language modeling, see `tutorial_ptb_lstm_state_is_tuple.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_ptb_lstm_state_is_tuple.py>`_.
33+
- Word Embedding - Word2vec. Train a word embedding matrix, see `tutorial_word2vec_basic.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial\_word2vec_basic.py>`_.
34+
- Restore Embedding matrix. Restore a pre-train embedding matrix, see `tutorial_generate_text.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_generate_text.py>`_.
35+
- Text Generation. Generates new text scripts, using LSTM network, see `tutorial_generate_text.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_generate_text.py>`_.
3736

3837
Adversarial Learning
3938
========================
@@ -45,9 +44,9 @@ Adversarial Learning
4544
Reinforcement Learning
4645
==============================
4746

48-
- Policy Gradient / Network - Pong Game. Teach a machine to play Pong games, see ``tutorial_atari_pong.py`` on `GitHub`_.
49-
- Q-Network - Frozen lake, see ``tutorial_frozenlake_q_network.py`` on `GitHub`_.
50-
- Q-Table learning algorithm - Frozen lake, see ``tutorial_frozenlake_q_table.py`` on `GitHub`_.
47+
- Policy Gradient / Network - Pong Game. Teach a machine to play Pong games, see `tutorial_atari_pong.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_atari_pong.py>`_.
48+
- Deep Q-Network - Frozen lake, see `tutorial_frozenlake_dqn.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_frozenlake_dqn.py>`_.
49+
- Q-Table learning algorithm - Frozen lake, see `tutorial_frozenlake_q_table.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_frozenlake_q_table.py>`_.
5150
- Asynchronous Deep Reinforcement Learning - Pong Game by `nebulaV <https://github.com/akaraspt/tl_paper>`_.
5251

5352
Applications
@@ -59,11 +58,10 @@ Applications
5958
Special Examples
6059
=================
6160

62-
- Merge TF-Slim into TensorLayer. ``tutorial_inceptionV3_tfslim.py`` on `GitHub`_.
63-
- Merge Keras into TensorLayer. ``tutorial_keras.py`` on `GitHub`_.
64-
- MultiplexerLayer. ``tutorial_mnist_multiplexer.py`` on `GitHub`_.
65-
- Data augmentation with TFRecord. Effective way to load and pre-process data, see ``tutorial_tfrecord*.py`` and ``tutorial_cifar10_tfrecord.py`` on `GitHub`_.
66-
- Data augmentation with TensorLayer, see ``tutorial_image_preprocess.py`` on `GitHub`_.
61+
- Merge TF-Slim into TensorLayer. `tutorial_inceptionV3_tfslim.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_inceptionV3_tfslim.py>`_.
62+
- Merge Keras into TensorLayer. `tutorial_keras.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_keras.py>`_.
63+
- Data augmentation with TFRecord. Effective way to load and pre-process data, see `tutorial_tfrecord*.py <https://github.com/zsdonghao/tensorlayer/tree/master/example>`_ and `tutorial_cifar10_tfrecord.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_cifar10_tfrecord.py>`_.
64+
- Data augmentation with TensorLayer, see `tutorial_image_preprocess.py <https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_image_preprocess.py>`_.
6765
- TensorDB by `fangde <https://github.com/fangde>`_ see `here <https://github.com/akaraspt/tl_paper>`_.
6866

6967
..

example/tutorial_frozenlake_q_network.py renamed to example/tutorial_frozenlake_dqn.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
import numpy as np
33
import tensorflow as tf
44
import tensorlayer as tl
5+
from tensorlayer.layers import *
56
import matplotlib.pyplot as plt
67

78
""" Q-Network Q(a, s) - TD Learning, Off-Policy, e-Greedy Exploration
89
910
Q(S, A) <- Q(S, A) + alpha * (R + lambda * Q(newS, newA) - Q(S, A))
10-
if alpha == 1: Q(S, A) <- R + lambda * Q(newS, newA)
11+
delta_w = R + lambda * Q(newS, newA)
12+
1113
See David Silver RL Tutorial Lecture 5 - Q-Learning for more details.
1214
1315
EN: https://medium.com/emergent-future/simple-reinforcement-learning-with-tensorflow-part-0-q-learning-with-tables-and-neural-networks-d195264329d0#.5m3361vlw
@@ -44,8 +46,8 @@ def to_one_hot(i, n_classes=None):
4446
## Define Q-network q(a,s) that ouput the rewards of 4 actions by given state, i.e. Action-Value Function.
4547
# 4x4 grid can be represented by one-hot vector with 16 integers.
4648
inputs = tf.placeholder(shape=[1, 16], dtype=tf.float32)
47-
net = tl.layers.InputLayer(inputs, name='observation')
48-
net = tl.layers.DenseLayer(net, n_units=4, act=tf.identity,
49+
net = InputLayer(inputs, name='observation')
50+
net = DenseLayer(net, n_units=4, act=tf.identity,
4951
W_init=tf.random_uniform_initializer(0, 0.01), b_init=None, name='q_a_s')
5052
y = net.outputs # action-value / rewards of 4 actions
5153
predict = tf.argmax(y, 1) # chose action greedily with reward
@@ -81,7 +83,8 @@ def to_one_hot(i, n_classes=None):
8183
## Obtain maxQ' and set our target value for chosen action.
8284
maxQ1 = np.max(Q1)
8385
targetQ = allQ
84-
targetQ[0, a[0]] = r + lambd * maxQ1
86+
# targetQ[0, a[0]] = r + lambd * maxQ1
87+
# targetQ[0, a[0]] = targetQ[0, a[0]] + alpha * (r + lambd * maxQ1 - targetQ[0, a[0]])
8588
## Train network using target and predicted Q values
8689
_ = sess.run(train_op, {inputs : [to_one_hot(s, 16)], nextQ : targetQ})
8790
rAll += r

example/tutorial_frozenlake_q_table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""Q-Table learning algorithm, non deep learning - TD Learning, Off-Policy, e-Greedy Exploration
55
66
Q(S, A) <- Q(S, A) + alpha * (R + lambda * Q(newS, newA) - Q(S, A))
7-
if alpha == 1: Q(S, A) <- R + lambda * Q(newS, newA)
7+
88
See David Silver RL Tutorial Lecture 5 - Q-Learning for more details.
99
1010
For Q-Network, see tutorial_frozenlake_q_network.py
@@ -22,7 +22,7 @@
2222
## Initialize table with all zeros
2323
Q = np.zeros([env.observation_space.n,env.action_space.n])
2424
## Set learning parameters
25-
lr = .85 # alpha
25+
lr = .85 # alpha, if use value function approximation, we can ignore it
2626
lambd = .99 # decay factor
2727
num_episodes = 10000
2828
rList = [] # rewards for each episode

0 commit comments

Comments
 (0)