Skip to content

Commit fd1cf2f

Browse files
authored
Fix some pydocstyle lints (tensorlayer#784)
* RTD with Mock Imports * cleanup docs (fix D208) * fix D300 * fix D402 * fix D412 * fix D204 * fix D403 * fix D207 * fix D301 * fix D200 * fix format * disable D302 * fix D210 * fix D202 * fix doc test and make it happen earlier * Issue with Deprecated Decorator Fixed * Changelog updated + YAPF cleaning * Update .readthedocs.yml * disable D202, since it has conflict with yapf * TF 1.6.0 Errors fixed * YAPF Cleaning * Doc Mock Import for ROI Pooling * TL init if protected * Error fix - Test Documentation * fix documentation test * update changelog
1 parent 0156da0 commit fd1cf2f

43 files changed

Lines changed: 377 additions & 353 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ branches:
1111
- /\d+\.\d+(\.\d+)?(\S*)?$/
1212

1313
python:
14-
- "2.7"
15-
- "3.5"
1614
- "3.6"
15+
- "3.5"
16+
- "2.7"
1717

1818
env:
1919

@@ -54,7 +54,7 @@ env:
5454

5555
matrix:
5656
include:
57-
- python: 3.6
57+
- python: '3.6'
5858
env:
5959
- _DOC_AND_YAPF_TEST=True
6060

CHANGELOG.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/)
@@ -69,6 +70,7 @@ To release a new version, please update the changelog as followed:
6970
## [Unreleased]
7071

7172
### Added
73+
7274
- API:
7375
- Add `tl.model.vgg19` (PR #698)
7476
- Add `tl.logging.contrib.hyperdash` (PR #739)
@@ -96,21 +98,27 @@ To release a new version, please update the changelog as followed:
9698
- `tutorial_mnist_distributed_trainer.py` and `tutorial_cifar10_distributed_trainer.py` are added to explain the uses of Distributed Trainer (PR #700)
9799
- add `tutorial_quanconv_cifar10.py` and `tutorial_quanconv_mnist.py` (PR #735)
98100
- add `tutorial_work_with_onnx.py`(PR #775)
101+
99102
### Changed
103+
100104
- function minibatches changed to avoid wasting samples.(PR #762)
101105
- all the input scale in both vgg16 and vgg19 has been changed the input scale from [0,255] to [0,1](PR #710)
102106
- Dockerfiles merged and refactored into one file (PR #747)
103107
- LazyImports move to the most **top level** imports as possible (PR #739)
104108
- some new test functions have been added in `test_layers_convolution.py`, `test_layers_normalization.py`, `test_layers_core.py` (PR #735)
105109
- documentation now uses mock imports reducing the number of dependencies to compile the documentation (PR #785)
110+
- fixed and enforced pydocstyle D210, D200, D301, D207, D403, D204, D412, D402, D300, D208 (PR #784)
106111

107112
### Deprecated
113+
108114
- `tl.logging.warn` has been deprecated in favor of `tl.logging.warning` (PR #739)
109115

110116
### Removed
117+
111118
- `conv_layers()` has been removed in both vgg16 and vgg19(PR #710)
112119

113120
### Fixed
121+
114122
- import error caused by matplotlib on OSX (PR #705)
115123
- missing import in tl.prepro (PR #712)
116124
- Dockerfiles import error fixed - issue #733 (PR #747)
@@ -120,13 +128,14 @@ To release a new version, please update the changelog as followed:
120128
### Security
121129

122130
### Dependencies Update
131+
123132
- tensorflow>=1.8,<1.9 => tensorflow>=1.9,<1.10 (PR #739)
124133
- tensorflow-gpu>=1.8,<1.9 => tensorflow-gpu>=1.9,<1.10 (PR #739)
125134
- pymongo>=3.6,<3.7 => pymongo>=3.7,<3.8 (PR #750)
126135
- numpy>=1.14,<1.15 => numpy>=1.15,<1.16 (PR #754)
127136

128-
129137
### Contributors
138+
130139
- @DEKHTIARJonathan: #739 #747 #750 #754
131140
- @lgarithm: #705 #700
132141
- @OwenLiuzZ: #698 #710 #775 #776
@@ -139,6 +148,7 @@ To release a new version, please update the changelog as followed:
139148
## [1.9.0] - 2018-06-16
140149

141150
### Added
151+
142152
- API:
143153
- `tl.alphas` and `tl.alphas_like` added following the tf.ones/zeros and tf.zeros_like/ones_like (PR #580)
144154
- `tl.lazy_imports.LazyImport` to import heavy libraries only when necessary (PR #667)
@@ -190,6 +200,7 @@ To release a new version, please update the changelog as followed:
190200
```
191201

192202
### Changed
203+
193204
- Tensorflow CPU & GPU dependencies moved to separated requirement files in order to allow PyUP.io to parse them (PR #573)
194205
- The document of LambdaLayer for linking it with ElementwiseLambdaLayer (PR #587)
195206
- RTD links point to stable documentation instead of latest used for development (PR #633)
@@ -214,15 +225,18 @@ To release a new version, please update the changelog as followed:
214225
- Complete Documentation Refactoring and Reorganization (namely Layer APIs) (PR #691)
215226

216227
### Deprecated
228+
217229
- `tl.layers.TimeDistributedLayer` argurment `args` is deprecated in favor of `layer_args` (PR #667)
218230
- `tl.act.leaky_relu` have been deprecated in favor of `tf.nn.leaky_relu` (PR #686)
219231

220232
### Removed
233+
221234
- `assert()` calls remove and replaced by `raise AssertionError()` (PR #667)
222235
- `tl.identity` is removed, not used anymore and deprecated for a long time (PR #667)
223236
- All Code specific to `TF.__version__ < "1.6"` have been removed (PR #675)
224237

225238
### Fixed
239+
226240
- Issue #498 - Deprecation Warning Fix in `tl.layers.RNNLayer` with `inspect` (PR #574)
227241
- Issue #498 - Deprecation Warning Fix in `tl.files` with truth value of an empty array is ambiguous (PR #575)
228242
- Issue #565 related to `tl.utils.predict` fixed - `np.hstack` problem in which the results for multiple batches are stacked along `axis=1` (PR #566)
@@ -240,13 +254,15 @@ To release a new version, please update the changelog as followed:
240254
- All tutorials tested and errors have been fixed (PR #635)
241255

242256
### Dependencies Update
257+
243258
- Update pytest from 3.5.1 to 3.6.0 (PR #647)
244259
- Update progressbar2 from 3.37.1 to 3.38.0 (PR #651)
245260
- Update scikit-image from 0.13.1 to 0.14.0 (PR #656)
246261
- Update keras from 2.1.6 to 2.2.0 (PR #684)
247262
- Update requests from 2.18.4 to 2.19.0 (PR #695)
248263

249264
### Contributors
265+
250266
- @lgarithm: #563
251267
- @DEKHTIARJonathan: #573 #574 #575 #580 #633 #635 #636 #639 #644 #645 #648 #657 #667 #658 #659 #660 #661 #666 #667 #672 #675 #683 #686 #687 #690 #691 #692 #703
252268
- @2wins: #560 #566 #662
@@ -258,6 +274,7 @@ To release a new version, please update the changelog as followed:
258274
## [1.8.5] - 2018-05-09
259275

260276
### Added
277+
261278
- Github Templates added (by @DEKHTIARJonathan)
262279
- New issues Template
263280
- New PR Template
@@ -270,6 +287,7 @@ To release a new version, please update the changelog as followed:
270287
- `test_layers_core` has been added to ensure that `LayersConfig` is abstract.
271288

272289
### Changed
290+
273291
- All Tests Refactored - Now using unittests and runned with PyTest (by @DEKHTIARJonathan)
274292
- Documentation updated (by @zsdonghao)
275293
- Package Setup Refactored (by @DEKHTIARJonathan)
@@ -280,6 +298,7 @@ To release a new version, please update the changelog as followed:
280298
- YAPF coding style improved and enforced (by @DEKHTIARJonathan)
281299

282300
### Fixed
301+
283302
- Backward Compatibility Restored with deprecation warnings (by @DEKHTIARJonathan)
284303
- Tensorflow Deprecation Fix (Issue #498):
285304
- AverageEmbeddingInputlayer (by @zsdonghao)
@@ -289,12 +308,13 @@ To release a new version, please update the changelog as followed:
289308
- Pooling Layer Issue #557 fixed (by @zsdonghao)
290309

291310
### Dependencies Update
311+
292312
- scipy>=1.0,<1.1 => scipy>=1.1,<1.2
293313

294314
### Contributors
315+
295316
@zsdonghao @luomai @DEKHTIARJonathan
296317

297318
[Unreleased]: https://github.com/tensorlayer/tensorlayer/compare/1.9.0...master
298319
[1.9.0]: https://github.com/tensorlayer/tensorlayer/compare/1.9.0...1.8.5
299320
[1.8.5]: https://github.com/tensorlayer/tensorlayer/compare/1.8.4...1.8.5
300-

docs/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
'sklearn',
7272
'tensorflow',
7373
'tqdm',
74+
75+
# TL C++ Packages
76+
'tensorlayer.third_party.roi_pooling.roi_pooling.roi_pooling_ops',
7477
]
7578

7679
# Add any paths that contain templates here, relative to this directory.

example/database/task_script.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
"""
2-
Sample task script.
1+
"""Sample task script."""
32

4-
"""
53
import tensorflow as tf
64
import tensorlayer as tl
75

@@ -58,8 +56,10 @@ def mlp(x, is_train=True, reuse=False):
5856
tl.layers.initialize_global_variables(sess)
5957

6058
# train the network
61-
tl.utils.fit(sess, net_train, train_op, cost, X_train, y_train, x, y_, acc=acc, batch_size=500, \
62-
n_epoch=1, print_freq=5, X_val=X_val, y_val=y_val, eval_train=False)
59+
tl.utils.fit(
60+
sess, net_train, train_op, cost, X_train, y_train, x, y_, acc=acc, batch_size=500, n_epoch=1, print_freq=5,
61+
X_val=X_val, y_val=y_val, eval_train=False
62+
)
6363

6464
# evaluation and save result that match the result_key
6565
test_accuracy = tl.utils.test(sess, net_test, acc_test, X_test, y_test, x, y_, batch_size=None, cost=cost_test)

example/tutorial_atari_pong.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /usr/bin/python
22
# -*- coding: utf-8 -*-
3-
""" Monte-Carlo Policy Network π(a|s) (REINFORCE).
3+
"""Monte-Carlo Policy Network π(a|s) (REINFORCE).
44
55
To understand Reinforcement Learning, we let computer to learn how to play
66
Pong game from the original screen inputs. Before we start, we highly recommend
@@ -45,7 +45,7 @@
4545

4646

4747
def prepro(I):
48-
""" prepro 210x160x3 uint8 frame into 6400 (80x80) 1D float vector """
48+
"""Prepro 210x160x3 uint8 frame into 6400 (80x80) 1D float vector."""
4949
I = I[35:195]
5050
I = I[::2, ::2, 0]
5151
I[I == 144] = 0
@@ -88,7 +88,8 @@ def prepro(I):
8888
start_time = time.time()
8989
game_number = 0
9090
while True:
91-
if render: env.render()
91+
if render:
92+
env.render()
9293

9394
cur_x = prepro(observation)
9495
x = cur_x - prev_x if prev_x is not None else np.zeros(D)
@@ -134,7 +135,11 @@ def prepro(I):
134135
prev_x = None
135136

136137
if reward != 0:
137-
print(('episode %d: game %d took %.5fs, reward: %f' % (episode_number, game_number, \
138-
time.time() - start_time, reward)), ('' if reward == -1 else ' !!!!!!!!'))
138+
print(
139+
(
140+
'episode %d: game %d took %.5fs, reward: %f' %
141+
(episode_number, game_number, time.time() - start_time, reward)
142+
), ('' if reward == -1 else ' !!!!!!!!')
143+
)
139144
start_time = time.time()
140145
game_number += 1

example/tutorial_binarynet_cifar10_tfrecord.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
model_file_name = "./model_cifar10_tfrecord.ckpt"
5151
resume = False # load model, resume from previous checkpoint?
5252

53-
## Download data, and convert to TFRecord format, see ```tutorial_tfrecord.py```
53+
# Download data, and convert to TFRecord format, see ```tutorial_tfrecord.py```
5454
X_train, y_train, X_test, y_test = tl.files.load_cifar10_dataset(shape=(-1, 32, 32, 3), plotable=False)
5555

5656
print('X_train.shape', X_train.shape) # (50000, 32, 32, 3)
@@ -61,7 +61,7 @@
6161

6262

6363
def data_to_tfrecord(images, labels, filename):
64-
""" Save data into TFRecord """
64+
"""Save data into TFRecord."""
6565
if os.path.isfile(filename):
6666
print("%s exists" % filename)
6767
return
@@ -70,11 +70,11 @@ def data_to_tfrecord(images, labels, filename):
7070
writer = tf.python_io.TFRecordWriter(filename)
7171
for index, img in enumerate(images):
7272
img_raw = img.tobytes()
73-
## Visualize a image
73+
# Visualize a image
7474
# tl.visualize.frame(np.asarray(img, dtype=np.uint8), second=1, saveable=False, name='frame', fig_idx=1236)
7575
label = int(labels[index])
7676
# print(label)
77-
## Convert the bytes back to image as follow:
77+
# Convert the bytes back to image as follow:
7878
# image = Image.frombytes('RGB', (32, 32), img_raw)
7979
# image = np.fromstring(img_raw, np.float32)
8080
# image = image.reshape([32, 32, 3])
@@ -92,7 +92,7 @@ def data_to_tfrecord(images, labels, filename):
9292

9393

9494
def read_and_decode(filename, is_train=None):
95-
""" Return tensor to read from TFRecord """
95+
"""Return tensor to read from TFRecord."""
9696
filename_queue = tf.train.string_input_producer([filename])
9797
reader = tf.TFRecordReader()
9898
_, serialized_example = reader.read(filename_queue)
@@ -136,7 +136,7 @@ def read_and_decode(filename, is_train=None):
136136
return img, label
137137

138138

139-
## Save data into TFRecord files
139+
# Save data into TFRecord files
140140
data_to_tfrecord(images=X_train, labels=y_train, filename="train.cifar10")
141141
data_to_tfrecord(images=X_test, labels=y_test, filename="test.cifar10")
142142

@@ -159,7 +159,7 @@ def read_and_decode(filename, is_train=None):
159159
)
160160

161161
def model(x_crop, y_, reuse):
162-
""" For more simplified CNN APIs, check tensorlayer.org """
162+
"""For more simplified CNN APIs, check tensorlayer.org."""
163163
with tf.variable_scope("model", reuse=reuse):
164164
net = tl.layers.InputLayer(x_crop, name='input')
165165
net = tl.layers.Conv2d(net, 64, (5, 5), (1, 1), act=tf.nn.relu, padding='SAME', name='cnn1')
@@ -191,8 +191,8 @@ def model(x_crop, y_, reuse):
191191

192192
return net, cost, acc
193193

194-
## You can also use placeholder to feed_dict in data after using
195-
## val, l = sess.run([x_train_batch, y_train_batch]) to get the data
194+
# You can also use placeholder to feed_dict in data after using
195+
# val, l = sess.run([x_train_batch, y_train_batch]) to get the data
196196
# x_crop = tf.placeholder(tf.float32, shape=[batch_size, 24, 24, 3])
197197
# y_ = tf.placeholder(tf.int32, shape=[batch_size,])
198198
# cost, acc, network = model(x_crop, y_, None)
@@ -201,7 +201,7 @@ def model(x_crop, y_, reuse):
201201
network, cost, acc, = model(x_train_batch, y_train_batch, False)
202202
_, cost_test, acc_test = model(x_test_batch, y_test_batch, True)
203203

204-
## train
204+
# train
205205
n_epoch = 50000
206206
learning_rate = 0.0001
207207
print_freq = 1
@@ -231,7 +231,7 @@ def model(x_crop, y_, reuse):
231231
start_time = time.time()
232232
train_loss, train_acc, n_batch = 0, 0, 0
233233
for s in range(n_step_epoch):
234-
## You can also use placeholder to feed_dict in data after using
234+
# You can also use placeholder to feed_dict in data after using
235235
# val, l = sess.run([x_train_batch, y_train_batch])
236236
# tl.visualize.images2d(val, second=3, saveable=False, name='batch', dtype=np.uint8, fig_idx=2020121)
237237
# err, ac, _ = sess.run([cost, acc, train_op], feed_dict={x_crop: val, y_: l})

example/tutorial_cifar10.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def model(x, y_, reuse):
4949

5050

5151
def model_batch_norm(x, y_, reuse, is_train):
52-
""" Batch normalization should be placed before rectifier. """
52+
"""Batch normalization should be placed before rectifier."""
5353
W_init = tf.truncated_normal_initializer(stddev=5e-2)
5454
W_init2 = tf.truncated_normal_initializer(stddev=0.04)
5555
b_init2 = tf.constant_initializer(value=0.1)
@@ -114,10 +114,10 @@ def distort_fn(x, is_train=False):
114114
x = tf.placeholder(dtype=tf.float32, shape=[None, 24, 24, 3], name='x')
115115
y_ = tf.placeholder(dtype=tf.int64, shape=[None], name='y_')
116116

117-
## using local response normalization
117+
# using local response normalization
118118
# network, cost, _ = model(x, y_, False)
119119
# _, cost_test, acc = model(x, y_, True)
120-
## you may want to try batch normalization
120+
# you may want to try batch normalization
121121
network, cost, _ = model_batch_norm(x, y_, False, is_train=True)
122122
_, cost_test, acc = model_batch_norm(x, y_, True, is_train=False)
123123

example/tutorial_cifar10_distributed_trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
"""
3+
r"""
44
1. Before you start, run this script: https://github.com/tensorlayer/tensorlayer/blob/distributed/scripts/download_and_install_openmpi3_linux.sh
55
2. Update the PATH with OpenMPI bin by running: PATH=$PATH:$HOME/local/openmpi/bin
66
Update the PATH in ~/.bashrc if you want OpenMPI to be ready once the machine start

0 commit comments

Comments
 (0)