diff --git a/README.md b/README.md index f1cb61ae9..e5f217e80 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ [![Documentation Status](https://readthedocs.org/projects/tensorlayer/badge/?version=latest)](http://tensorlayer.readthedocs.io/en/latest/?badge=latest) [![Docker Pulls](https://img.shields.io/docker/pulls/tensorlayer/tensorlayer.svg?maxAge=604800)](https://hub.docker.com/r/tensorlayer/tensorlayer/) -TensorLayer is a deep learning and reinforcement learning library on top of [TensorFlow](https://www.tensorflow.org). It provides rich neural layers and utility functions to help researchers and engineers build real-world AI applications. TensorLayer is awarded the 2017 Best Open Source Software Award by the prestigious [ACM Multimedia Society](http://www.acmmm.org/2017/mm-2017-awardees/). +TensorLayer is a deep learning and reinforcement learning library on top of [TensorFlow](https://www.tensorflow.org). It provides rich neural layers and utility functions to help researchers and engineers build real-world AI applications. TensorLayer is awarded the 2017 Best Open Source Software by the prestigious [ACM Multimedia Society](http://www.acmmm.org/2017/mm-2017-awardees/). - Useful links: [Documentation](http://tensorlayer.readthedocs.io), [Examples](http://tensorlayer.readthedocs.io/en/latest/user/example.html), [中文文档](https://tensorlayercn.readthedocs.io), [中文书](http://www.broadview.com.cn/book/5059) @@ -116,7 +116,7 @@ Examples can be found [in this folder](https://github.com/zsdonghao/tensorlayer/ - Float 16 half-precision model, see [tutorial\_mnist_float16.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_mnist_float16.py) ## Notes -TensorLayer provides two set of Convolutional layer APIs, see [(Professional)](http://tensorlayer.readthedocs.io/en/latest/modules/layers.html#convolutional-layer-pro) and [(Simplified)](http://tensorlayer.readthedocs.io/en/latest/modules/layers.html#convolutional-layer-simplified) on readthedocs website. +TensorLayer provides two set of Convolutional layer APIs, see [(Advanced)](http://tensorlayer.readthedocs.io/en/latest/modules/layers.html#convolutional-layer-pro) and [(Basic)](http://tensorlayer.readthedocs.io/en/latest/modules/layers.html#convolutional-layer-simplified) on readthedocs website. [h, w, 3] return im_train_A, im_train_B, im_test_A, im_test_B -def download_file_from_google_drive(id, destination): +def download_file_from_google_drive(ID, destination): """Download file from Google Drive. See ``tl.files.load_celebA_dataset`` for example. Parameters -------------- - id : str + ID : str The driver ID. destination : str The destination for save file. @@ -782,11 +783,11 @@ def get_confirm_token(response): URL = "https://docs.google.com/uc?export=download" session = requests.Session() - response = session.get(URL, params={'id': id}, stream=True) + response = session.get(URL, params={'id': ID}, stream=True) token = get_confirm_token(response) if token: - params = {'id': id, 'confirm': token} + params = {'id': ID, 'confirm': token} response = session.get(URL, params=params, stream=True) save_response_content(response, destination) @@ -1613,7 +1614,7 @@ def load_file_list(path=None, regx='\.npz', printable=True): path = os.getcwd() file_list = os.listdir(path) return_list = [] - for idx, f in enumerate(file_list): + for _, f in enumerate(file_list): if re.search(regx, f): return_list.append(f) # return_list.sort() diff --git a/tensorlayer/layers/convolution.py b/tensorlayer/layers/convolution.py index a103739fc..33e6d1b82 100644 --- a/tensorlayer/layers/convolution.py +++ b/tensorlayer/layers/convolution.py @@ -59,7 +59,7 @@ def __init__( act = tf.identity logging.info("Conv1dLayer %s: shape:%s stride:%s pad:%s act:%s" % (self.name, str(shape), str(stride), padding, act.__name__)) - with tf.variable_scope(name) as vs: + with tf.variable_scope(name): # as vs: W = tf.get_variable(name='W_conv1d', shape=shape, initializer=W_init, dtype=D_TYPE, **W_init_args) self.outputs = tf.nn.convolution( self.inputs, W, strides=(stride, ), padding=padding, dilation_rate=(dilation_rate, ), data_format=data_format) # 1.2 diff --git a/tensorlayer/prepro.py b/tensorlayer/prepro.py index 35d786d8d..85970e9f9 100644 --- a/tensorlayer/prepro.py +++ b/tensorlayer/prepro.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import sys import threading import time @@ -8,20 +7,13 @@ import scipy import scipy.ndimage as ndi import skimage -import tensorlayer as tl +# import tensorlayer as tl from scipy import linalg from scipy.ndimage.filters import gaussian_filter from scipy.ndimage.interpolation import map_coordinates from six.moves import range from skimage import exposure, transform -# import Queue # <-- donot work for py3 -is_py2 = sys.version[0] == '2' -if is_py2: - import Queue as queue -else: - import queue as queue - # linalg https://docs.scipy.org/doc/scipy/reference/linalg.html # ndimage https://docs.scipy.org/doc/scipy/reference/ndimage.html @@ -1416,7 +1408,7 @@ def get_zca_whitening_principal_components_img(X): logging.info("zca : computing sigma ..") sigma = np.dot(flatX.T, flatX) / flatX.shape[0] logging.info("zca : computing U, S and V ..") - U, S, V = linalg.svd(sigma) + U, S, _ = linalg.svd(sigma) # USV logging.info("zca : computing principal components ..") principal_components = np.dot(np.dot(U, np.diag(1. / np.sqrt(S + 10e-7))), U.T) return principal_components @@ -1884,7 +1876,7 @@ def binary_erosion(x, radius=3): A processed binary image. """ - from skimage.morphology import disk, dilation, binary_erosion + from skimage.morphology import disk, binary_erosion mask = disk(radius) x = binary_erosion(x, selem=mask) return x @@ -1907,7 +1899,7 @@ def erosion(x, radius=3): A processed greyscale image. """ - from skimage.morphology import disk, dilation, erosion + from skimage.morphology import disk, erosion mask = disk(radius) x = erosion(x, selem=mask) return x @@ -2913,7 +2905,7 @@ def process_sequences(sequences, end_id=0, pad_val=0, is_shorten=True, remain_en """ max_length = 0 - for i_s, seq in enumerate(sequences): + for _, seq in enumerate(sequences): is_end = False for i_w, n in enumerate(seq): if n == end_id and is_end == False: # 1st time to see end_id diff --git a/tensorlayer/utils.py b/tensorlayer/utils.py index 90a47bef5..a63ff6e57 100644 --- a/tensorlayer/utils.py +++ b/tensorlayer/utils.py @@ -370,10 +370,10 @@ def evaluation(y_test=None, y_predict=None, n_classes=None): return c_mat, f1, acc, f1_macro -def dict_to_one(dp_dict={}): - """ - Input a dictionary, return a dictionary that all items are set to one, - use for disable dropout, dropconnect layer and so on. +def dict_to_one(dp_dict): + """Input a dictionary, return a dictionary that all items are set to one. + + Used for disable dropout, dropconnect layer and so on. Parameters ---------- @@ -390,9 +390,8 @@ def dict_to_one(dp_dict={}): return {x: 1 for x in dp_dict} -def flatten_list(list_of_list=[[], []]): - """ - Input a list of list, return a list that all items are in a list. +def flatten_list(list_of_list): + """Input a list of list, return a list that all items are in a list. Parameters ---------- diff --git a/tests/testing.py b/tests/testing.py index 26594bb7b..dafaf26a0 100644 --- a/tests/testing.py +++ b/tests/testing.py @@ -2,7 +2,7 @@ def _list_py_files(root): - for root, dirs, files in os.walk(root): + for root, _dirs, files in os.walk(root): if root.find('third_party') != -1: continue for file in files: