Skip to content

Commit cb4eb89

Browse files
authored
Update TensorLayer (#1148)
1 parent 14ca69e commit cb4eb89

36 files changed

+57
-112
lines changed

.circleci/config.yml

-2
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,11 @@ jobs:
482482
command: |
483483
echo "start tag workflow"
484484
485-
###################################################################################
486485
###################################################################################
487486
###################################################################################
488487
# CircleCI WORKFLOWS #
489488
###################################################################################
490489
###################################################################################
491-
###################################################################################
492490

493491
workflows:
494492
version: 2

.codacy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
---
33
engines:
44
bandit:
5-
enabled: false # FIXME: make it works
5+
enabled: false
66
exclude_paths:
77
- scripts/*
88
- setup.py

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# dockerignore
12
.git

.github/changelog.yml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ include:
1818
- requirements_dev.txt
1919
- requirements_tf_cpu.txt
2020
- requirements_tf_gpu.txt
21+
- requirements_doc.txt
22+
- requirements_test.txt
2123

2224
# Configuration Files
2325
- .travis.yml

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ wheels/
2626
MANIFEST
2727
*~
2828

29-
# PyInstaller
3029
# Usually these files are written by a python script from a template
3130
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3231
*.manifest

.pyup.yml

-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ requirements:
5757
# Requirements for running unittests
5858
- requirements/requirements_test.txt
5959

60-
# add a label to pull requests, default is not set
61-
# requires private repo permissions, even on public repos
62-
# default: empty
63-
#label_prs: update
64-
6560
# configure the branch prefix the bot is using
6661
# default: pyup-
6762
branch_prefix: pyup-

.readthedocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# https://docs.readthedocs.io/en/latest/yaml-config.html
22

33
build:
4-
image: latest # For python 3.6
4+
image: latest
55

66
formats:
77
- epub

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ make html
140140
# An example of a static model
141141
# A static model has inputs and outputs with fixed shape.
142142
inputs = tl.layers.Input([32, 784])
143-
dense1 = tl.layers.Dense(n_units=800, act=tf.nn.relu, in_channels=784, name='dense1')(inputs)
144-
dense2 = tl.layers.Dense(n_units=10, act=tf.nn.relu, in_channels=800, name='dense2')(dense1)
143+
dense1 = tl.layers.Dense(n_units=800, act='relu', in_channels=784, name='dense1')(inputs)
144+
dense2 = tl.layers.Dense(n_units=10, act='relu', in_channels=800, name='dense2')(dense1)
145145
model = tl.models.Model(inputs=inputs, outputs=dense2)
146146

147147
# An example of a dynamic model
148148
# A dynamic model has more flexibility. The inputs and outputs may be different in different runs.
149149
class CustomizeModel(tl.models.Model):
150150
def __init__(self):
151151
super(CustomizeModel, self).__init__()
152-
self.dense1 = tl.layers.Dense(n_units=800, act=tf.nn.relu, in_channels=784, name='dense1')
153-
self.dense2 = tl.layers.Dense(n_units=10, act=tf.nn.relu, in_channels=800, name='dense2')
152+
self.dense1 = tl.layers.Dense(n_units=800, act='relu', in_channels=784, name='dense1')
153+
self.dense2 = tl.layers.Dense(n_units=10, act='relu', in_channels=800, name='dense2')
154154

155155
# a dynamic model allows more flexibility by customising forwarding.
156156
def forward(self, x, bar=None):

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<!--- [![PyUP Updates](https://pyup.io/repos/github/tensorlayer/tensorlayer/shield.svg)](https://pyup.io/repos/github/tensorlayer/tensorlayer/) --->
2323

2424
[TensorLayer](https://tensorlayer.readthedocs.io) is a novel TensorFlow-based deep learning and reinforcement learning library designed for researchers and engineers. It provides an extensive collection of customizable neural layers to build advanced AI models quickly, based on this, the community open-sourced mass [tutorials](https://github.com/tensorlayer/tensorlayer/blob/master/examples/reinforcement_learning/README.md) and [applications](https://github.com/tensorlayer). TensorLayer is awarded the 2017 Best Open Source Software by the [ACM Multimedia Society](https://twitter.com/ImperialDSI/status/923928895325442049).
25-
This project can also be found at [iHub](https://code.ihub.org.cn/projects/328) and [Gitee](https://gitee.com/organizations/TensorLayer).
25+
This project can also be found at [OpenI](https://git.openi.org.cn/TensorLayer/tensorlayer3.0) and [Gitee](https://gitee.com/organizations/TensorLayer).
2626

2727
# News
2828

README.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Cite
107107
====
108108

109109
If you find this project useful, we would be grateful if you cite the
110-
TensorLayer paper:
110+
TensorLayer papers.
111111

112112
::
113113

@@ -119,6 +119,14 @@ TensorLayer paper:
119119
year = {2017}
120120
}
121121

122+
@inproceedings{tensorlayer2021,
123+
title={Tensorlayer 3.0: A Deep Learning Library Compatible With Multiple Backends},
124+
author={Lai, Cheng and Han, Jiarong and Dong, Hao},
125+
booktitle={2021 IEEE International Conference on Multimedia \& Expo Workshops (ICMEW)},
126+
pages={1--3},
127+
year={2021},
128+
organization={IEEE}
129+
122130
License
123131
=======
124132

docker/pypi_list.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
args = parser.parse_args()
1616

17-
# create logger
1817
logger = logging.getLogger("PyPI_CLI")
1918

2019
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')

docker/version_prefix.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
args = parser.parse_args()
1515

16-
# create logger
1716
logger = logging.getLogger("VERSION_PREFIX_CLI")
1817

1918
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')

docs/conf.py

-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3535
# ones.
3636

37-
# extensions = [
38-
# 'sphinx.ext.coverage',
39-
# 'sphinx.ext.githubpages',
40-
# 'numpydoc',
41-
# ]
42-
4337
extensions = [
4438
'sphinx.ext.autodoc',
4539
'sphinx.ext.autosummary',

examples/basic_tutorials/tutorial_cifar10_cnn_static.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,21 @@ def _map_fn_test(img, target):
136136
train_ds = tf.data.Dataset.from_generator(
137137
generator_train, output_types=(tf.float32, tf.int32)
138138
) # , output_shapes=((24, 24, 3), (1)))
139-
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
140139
# train_ds = train_ds.repeat(n_epoch)
141140
train_ds = train_ds.shuffle(shuffle_buffer_size)
142141
train_ds = train_ds.prefetch(buffer_size=4096)
143142
train_ds = train_ds.batch(batch_size)
143+
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
144144
# value = train_ds.make_one_shot_iterator().get_next()
145145

146146
test_ds = tf.data.Dataset.from_generator(
147147
generator_test, output_types=(tf.float32, tf.int32)
148148
) # , output_shapes=((24, 24, 3), (1)))
149149
# test_ds = test_ds.shuffle(shuffle_buffer_size)
150-
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
151150
# test_ds = test_ds.repeat(n_epoch)
152151
test_ds = test_ds.prefetch(buffer_size=4096)
153152
test_ds = test_ds.batch(batch_size)
153+
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
154154
# value_test = test_ds.make_one_shot_iterator().get_next()
155155

156156
for epoch in range(n_epoch):

examples/data_process/tutorial_fast_affine_transform.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def _map_fn(image_path, target):
9898
dataset = tf.data.Dataset.from_generator(generator, output_types=(tf.string, tf.int64))
9999
dataset = dataset.shuffle(buffer_size=4096) # shuffle before loading images
100100
dataset = dataset.repeat(n_epoch)
101-
dataset = dataset.map(_map_fn, num_parallel_calls=multiprocessing.cpu_count())
102101
dataset = dataset.batch(batch_size) # TODO: consider using tf.contrib.map_and_batch
102+
dataset = dataset.map(_map_fn, num_parallel_calls=multiprocessing.cpu_count())
103103
dataset = dataset.prefetch(1) # prefetch 1 batch
104104

105105
n_step = 0

examples/data_process/tutorial_tf_dataset_voc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ def _map_fn(filename, annotation):
8989

9090
ds = tf.data.Dataset.from_generator(generator, output_types=(tf.string, tf.string))
9191
ds = ds.shuffle(shuffle_buffer_size)
92-
ds = ds.map(_map_fn, num_parallel_calls=multiprocessing.cpu_count())
9392
ds = ds.repeat(n_epoch)
9493
ds = ds.prefetch(buffer_size=2048)
9594
ds = ds.batch(batch_size)
95+
ds = ds.map(_map_fn, num_parallel_calls=multiprocessing.cpu_count())
9696

9797
st = time.time()
9898
im, annbyte = next(iter(ds))

examples/data_process/tutorial_tfrecord.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@
7777
def read_and_decode(filename):
7878
# generate a queue with a given file name
7979
raw_dataset = tf.data.TFRecordDataset([filename]).shuffle(1000).batch(4)
80+
features = {}
8081
for serialized_example in raw_dataset:
81-
features = tf.io.parse_example(
82-
serialized_example, features={
83-
'label': tf.io.FixedLenFeature([], tf.int64),
84-
'img_raw': tf.io.FixedLenFeature([], tf.string),
85-
}
86-
)
82+
features['label'] = tf.io.FixedLenFeature([], tf.int64)
83+
features['img_raw'] = tf.io.FixedLenFeature([], tf.string)
84+
features = tf.io.parse_example(serialized_example, features)
8785
# You can do more image distortion here for training data
8886
img_batch = tf.io.decode_raw(features['img_raw'], tf.uint8)
8987
img_batch = tf.reshape(img_batch, [4, 224, 224, 3])

examples/data_process/tutorial_tfrecord2.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@
6363
def read_and_decode(filename):
6464
batchsize = 4
6565
raw_dataset = tf.data.TFRecordDataset([filename]).shuffle(1000).batch(batchsize)
66+
features = {}
6667
for serialized_example in raw_dataset:
67-
features = tf.io.parse_example(
68-
serialized_example, features={
69-
'label': tf.io.FixedLenFeature([], tf.int64),
70-
'img_raw': tf.io.FixedLenFeature([], tf.string),
71-
}
72-
)
68+
features['label'] = tf.io.FixedLenFeature([], tf.int64)
69+
features['img_raw'] = tf.io.FixedLenFeature([], tf.string)
70+
features = tf.io.parse_example(serialized_example, features)
7371
# You can do more image distortion here for training data
7472
img_batch = tf.io.decode_raw(features['img_raw'], tf.uint8)
7573
img_batch = tf.reshape(img_batch, [-1, 32, 32, 3])

examples/quantized_net/tutorial_binarynet_cifar10_tfrecord.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,21 @@ def accuracy(_logits, y_batch):
161161
train_ds = tf.data.Dataset.from_generator(
162162
generator_train, output_types=(tf.float32, tf.int32)
163163
) # , output_shapes=((24, 24, 3), (1)))
164-
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
165164
# train_ds = train_ds.repeat(n_epoch)
166165
train_ds = train_ds.shuffle(shuffle_buffer_size)
167166
train_ds = train_ds.prefetch(buffer_size=4096)
168167
train_ds = train_ds.batch(batch_size)
168+
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
169169
# value = train_ds.make_one_shot_iterator().get_next()
170170

171171
test_ds = tf.data.Dataset.from_generator(
172172
generator_test, output_types=(tf.float32, tf.int32)
173173
) # , output_shapes=((24, 24, 3), (1)))
174174
# test_ds = test_ds.shuffle(shuffle_buffer_size)
175-
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
176175
# test_ds = test_ds.repeat(n_epoch)
177176
test_ds = test_ds.prefetch(buffer_size=4096)
178177
test_ds = test_ds.batch(batch_size)
178+
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
179179
# value_test = test_ds.make_one_shot_iterator().get_next()
180180

181181
for epoch in range(n_epoch):

examples/quantized_net/tutorial_dorefanet_cifar10_tfrecord.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,21 @@ def accuracy(_logits, y_batch):
154154
train_ds = tf.data.Dataset.from_generator(
155155
generator_train, output_types=(tf.float32, tf.int32)
156156
) # , output_shapes=((24, 24, 3), (1)))
157-
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
158157
# train_ds = train_ds.repeat(n_epoch)
159158
train_ds = train_ds.shuffle(shuffle_buffer_size)
160159
train_ds = train_ds.prefetch(buffer_size=4096)
161160
train_ds = train_ds.batch(batch_size)
161+
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
162162
# value = train_ds.make_one_shot_iterator().get_next()
163163

164164
test_ds = tf.data.Dataset.from_generator(
165165
generator_test, output_types=(tf.float32, tf.int32)
166166
) # , output_shapes=((24, 24, 3), (1)))
167167
# test_ds = test_ds.shuffle(shuffle_buffer_size)
168-
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
169168
# test_ds = test_ds.repeat(n_epoch)
170169
test_ds = test_ds.prefetch(buffer_size=4096)
171170
test_ds = test_ds.batch(batch_size)
171+
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
172172
# value_test = test_ds.make_one_shot_iterator().get_next()
173173

174174
for epoch in range(n_epoch):

examples/quantized_net/tutorial_quanconv_cifar10.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,21 @@ def accuracy(_logits, y_batch):
151151
train_ds = tf.data.Dataset.from_generator(
152152
generator_train, output_types=(tf.float32, tf.int32)
153153
) # , output_shapes=((24, 24, 3), (1)))
154-
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
155154
# train_ds = train_ds.repeat(n_epoch)
156155
train_ds = train_ds.shuffle(shuffle_buffer_size)
157156
train_ds = train_ds.prefetch(buffer_size=4096)
158157
train_ds = train_ds.batch(batch_size)
158+
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
159159
# value = train_ds.make_one_shot_iterator().get_next()
160160

161161
test_ds = tf.data.Dataset.from_generator(
162162
generator_test, output_types=(tf.float32, tf.int32)
163163
) # , output_shapes=((24, 24, 3), (1)))
164164
# test_ds = test_ds.shuffle(shuffle_buffer_size)
165-
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
166165
# test_ds = test_ds.repeat(n_epoch)
167166
test_ds = test_ds.prefetch(buffer_size=4096)
168167
test_ds = test_ds.batch(batch_size)
168+
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
169169
# value_test = test_ds.make_one_shot_iterator().get_next()
170170

171171
for epoch in range(n_epoch):

examples/quantized_net/tutorial_ternaryweight_cifar10_tfrecord.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,21 @@ def accuracy(_logits, y_batch):
160160
train_ds = tf.data.Dataset.from_generator(
161161
generator_train, output_types=(tf.float32, tf.int32)
162162
) # , output_shapes=((24, 24, 3), (1)))
163-
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
164163
# train_ds = train_ds.repeat(n_epoch)
165164
train_ds = train_ds.shuffle(shuffle_buffer_size)
166165
train_ds = train_ds.prefetch(buffer_size=4096)
167166
train_ds = train_ds.batch(batch_size)
167+
train_ds = train_ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
168168
# value = train_ds.make_one_shot_iterator().get_next()
169169

170170
test_ds = tf.data.Dataset.from_generator(
171171
generator_test, output_types=(tf.float32, tf.int32)
172172
) # , output_shapes=((24, 24, 3), (1)))
173173
# test_ds = test_ds.shuffle(shuffle_buffer_size)
174-
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
175174
# test_ds = test_ds.repeat(n_epoch)
176175
test_ds = test_ds.prefetch(buffer_size=4096)
177176
test_ds = test_ds.batch(batch_size)
177+
test_ds = test_ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
178178
# value_test = test_ds.make_one_shot_iterator().get_next()
179179

180180
for epoch in range(n_epoch):

examples/reinforcement_learning/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ A corresponding [Springer textbook](https://deepreinforcementlearningbook.org) i
5050

5151
`pip install --upgrade tf-nightly-2.0-preview tfp-nightly`
5252

53+
## Quick Start
54+
```
55+
conda create --name tl python=3.6.4
56+
conda activate tl
57+
pip install tensorflow-gpu==2.0.0-rc1 # if no GPU, use pip install tensorflow==2.0.0
58+
pip install tensorlayer
59+
pip install tensorflow-probability==0.9.0
60+
pip install gym
61+
pip install gym[atari] # for others, use pip instal gym[all]
62+
63+
python tutorial_DDPG.py --train
64+
```
65+
5366
## Status: Beta
5467

5568
We are currently open to any suggestions or pull requests from you to make the reinforcement learning tutorial with TensorLayer2.0 a better code repository for both new learners and senior researchers. Some of the algorithms mentioned in the this markdown may be not yet available, since we are still trying to implement more RL algorithms and optimize their performances. However, those algorithms listed above will come out in a few weeks, and the repository will keep updating more advanced RL algorithms in the future.

img/medium/Readme.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ It is 72px tall and can have a maximum width of 600px.
1515

1616
## Publication homepage images
1717

18-
Under Homepage and settings > Layout, you can select a header size, upload a logo and add a background image (large header size only).
19-
18+
Under Homepage and settings > Layout, you can select a header size, upload a logo and add a background image (large header size only).

requirements/requirements_tf_gpu.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
tensorflow-gpu>=2.0.0-alpha0
1+
tensorflow-gpu>=2.0.0-rc1

scripts/download_and_install_openmpi3_ubuntu.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ URL=https://download.open-mpi.org/release/open-mpi/v${MPI_MAJOR}.${MPI_MINOR}/${
2323
tar -xf ${FILENAME}
2424
cd ${FOLDER}
2525

26-
# will take about 8 min or longer depends on your machine
26+
# will take about 8 min or longer depends on your machine.
2727
./configure --prefix=$HOME/local/openmpi
2828
make -j ${NPROC} all
2929
make install

scripts/install-requirements-for-rtd.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# This script is for installing horovod on readthedocs only!
2+
23
set -e
34

45
pwd

setup.cfg

-15
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,6 @@ column_limit=120
3030
each_dict_entry_on_separate_line = True
3131

3232
# Put closing brackets on a separate line, dedented, if the bracketed
33-
# expression can't fit in a single line. Applies to all kinds of brackets,
34-
# including function definitions and calls. For example:
35-
#
36-
# config = {
37-
# 'key1': 'value1',
38-
# 'key2': 'value2',
39-
# } # <--- this bracket is dedented and on a separate line
40-
#
41-
# time_series = self.remote_client.query_entity_counters(
42-
# entity='dev3246.region1',
43-
# key='dns.query_latency_tcp',
44-
# transform=Transformation.AVERAGE(window=timedelta(seconds=60)),
45-
# start_ts=now()-timedelta(days=3),
46-
# end_ts=now(),
47-
# ) # <--- this bracket is dedented and on a separate line
4833
dedent_closing_brackets=True
4934

5035
# Do not split consecutive brackets. Only relevant when DEDENT_CLOSING_BRACKETS is set

0 commit comments

Comments
 (0)