From 6fea9d9d165da88e3354f723c89a0a6ccf7d8e53 Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Fri, 7 Sep 2018 06:59:52 -0700 Subject: [PATCH] PyUP - Dependency Update Scheduled daily dependency update on thursday (#823) * Pin imageio to latest version 2.4.0 * Pin pytest to latest version 3.8.0 * Update requirements_test.txt * Update requirements.txt * Update CHANGELOG.md * YAPF Applied * YAPF Corrections Applied --- CHANGELOG.md | 8 +++++-- requirements/requirements.txt | 4 ++-- requirements/requirements_test.txt | 2 +- tensorlayer/cost.py | 4 ++-- tensorlayer/db.py | 12 ++++------ tensorlayer/decorators/deprecated.py | 4 ++-- tensorlayer/distributed.py | 6 ++--- .../files/dataset_loaders/mpii_dataset.py | 2 +- tensorlayer/files/utils.py | 2 +- tensorlayer/iterate.py | 2 +- tensorlayer/layers/convolution/atrous_conv.py | 8 +++---- tensorlayer/layers/convolution/binary_conv.py | 4 ++-- .../layers/convolution/depthwise_conv.py | 4 ++-- tensorlayer/layers/convolution/dorefa_conv.py | 4 ++-- tensorlayer/layers/convolution/expert_conv.py | 12 +++++----- .../layers/convolution/expert_deconv.py | 8 +++---- tensorlayer/layers/convolution/group_conv.py | 4 ++-- tensorlayer/layers/convolution/quan_conv.py | 4 ++-- .../layers/convolution/quan_conv_bn.py | 4 ++-- .../layers/convolution/separable_conv.py | 8 +++---- .../layers/convolution/simplified_conv.py | 8 +++---- .../layers/convolution/simplified_deconv.py | 8 +++---- .../layers/convolution/ternary_conv.py | 4 ++-- tensorlayer/layers/core.py | 5 ++-- tensorlayer/layers/recurrent.py | 6 ++--- tensorlayer/prepro.py | 12 +++++----- tests/test_layers_recurrent.py | 24 +++++++++---------- 27 files changed, 87 insertions(+), 86 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eae42d93..7fdca76f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ To release a new version, please update the changelog as followed: ## [Unreleased] ### Added +- unittest `tests\test_timeout.py` has been added to ensure the network creation process does not freeze. ### Changed - remove 'tensorboard' param, replaced by 'tensorboard_dir' in `tensorlayer/utils.py` with customizable tensorboard directory (PR #819) @@ -77,6 +78,7 @@ To release a new version, please update the changelog as followed: ### Deprecated ### Removed +- TL Graph API removed. Memory Leaks Issues with this API, will be fixed and integrated in TL 2.0 (PR #818) ### Fixed @@ -85,11 +87,13 @@ To release a new version, please update the changelog as followed: ### Dependencies Update - autopep8>=1.3,<1.4 => autopep8>=1.3,<1.5 (PR #815) - pytest-cov>=2.5,<2.6 => pytest-cov>=2.5,<2.7 (PR #820) +- pytest>=3.6,<3.8 => pytest>=3.6,<3.9 (PR #823) +- imageio>=2.3,<2.4 => imageio>=2.3,<2.5 (PR #823) ### Contributors +- @DEKHTIARJonathan: #815 #818 #820 #823 - @ndiy: #819 - -- @DEKHTIARJonathan: #815 #820 +- @zsdonghao: #818 ## [1.10.0] - 2018-09-02 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 97a7004a5..0230cd7c4 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,4 +1,4 @@ -imageio>=2.3,<2.4 +imageio>=2.3,<2.5 lxml>=4.2,<4.3 matplotlib>=2.2,<2.3 numpy>=1.14,<1.16 @@ -8,4 +8,4 @@ scikit-learn>=0.19,<0.20 scikit-image>=0.14,<0.15 scipy>=1.1,<1.2 tqdm>=4.23,<4.26 -wrapt>=1.10,<1.11 \ No newline at end of file +wrapt>=1.10,<1.11 diff --git a/requirements/requirements_test.txt b/requirements/requirements_test.txt index 2e647c2f7..8cacae487 100644 --- a/requirements/requirements_test.txt +++ b/requirements/requirements_test.txt @@ -1,7 +1,7 @@ keras>=2.2,<2.3 pycodestyle>=2.0,<2.5 pydocstyle>=2.1,<2.2 -pytest>=3.6,<3.8 +pytest>=3.6,<3.9 pytest-cache>=1.0,<1.1 pytest-cov>=2.5,<2.7 pytest-xdist>=1.22,<1.24 diff --git a/tensorlayer/cost.py b/tensorlayer/cost.py index 0ee6b8a50..4d82213ca 100644 --- a/tensorlayer/cost.py +++ b/tensorlayer/cost.py @@ -259,7 +259,7 @@ def dice_coe(output, target, loss_type='jaccard', axis=(1, 2, 3), smooth=1e-5): # epsilon = 1e-5 # dice = tf.clip_by_value(dice, 0, 1.0-epsilon) # if all empty, dice = 1 # new haodong - dice = (2. * inse + smooth) / (l +r+ smooth) + dice = (2. * inse + smooth) / (l + r + smooth) ## dice = tf.reduce_mean(dice, name='dice_coe') return dice @@ -298,7 +298,7 @@ def dice_hard_coe(output, target, threshold=0.5, axis=(1, 2, 3), smooth=1e-5): # epsilon = 1e-5 # hard_dice = tf.clip_by_value(hard_dice, 0, 1.0-epsilon) # new haodong - hard_dice = (2. * inse + smooth) / (l +r+ smooth) + hard_dice = (2. * inse + smooth) / (l + r + smooth) ## hard_dice = tf.reduce_mean(hard_dice, name='hard_dice') return hard_dice diff --git a/tensorlayer/db.py b/tensorlayer/db.py index 80a8a6b4f..3e8656641 100644 --- a/tensorlayer/db.py +++ b/tensorlayer/db.py @@ -219,9 +219,8 @@ def find_top_model(self, sess, sort=None, model_name='model', **kwargs): pc = self.db.Model.find(kwargs) print( - "[Database] Find one model SUCCESS. kwargs:{} sort:{} save time:{} took: {}s".format( - kwargs, sort, _datetime, round(time.time() - s, 2) - ) + "[Database] Find one model SUCCESS. kwargs:{} sort:{} save time:{} took: {}s". + format(kwargs, sort, _datetime, round(time.time() - s, 2)) ) # put all informations of model into the TL layer @@ -656,10 +655,9 @@ def run_top_task(self, task_name=None, sort=None, **kwargs): }}, return_document=pymongo.ReturnDocument.AFTER ) logging.info( - "[Database] Finished Task: task_name - {} sort: {} push time: {} took: {}s".format( - task_name, sort, _datetime, - time.time() - s - ) + "[Database] Finished Task: task_name - {} sort: {} push time: {} took: {}s". + format(task_name, sort, _datetime, + time.time() - s) ) return True except Exception as e: diff --git a/tensorlayer/decorators/deprecated.py b/tensorlayer/decorators/deprecated.py index 90854f6f1..e3df14c2b 100644 --- a/tensorlayer/decorators/deprecated.py +++ b/tensorlayer/decorators/deprecated.py @@ -44,8 +44,8 @@ def wrapper(wrapped, instance=None, args=None, kwargs=None): '%s: `%s.%s` (in file: %s) is deprecated and will be removed %s.\n' 'Instructions for updating: %s\n' % ( "Class" if inspect.isclass(wrapped) else "Function", wrapped.__module__, class_or_func_name, - wrapped.__code__.co_filename, 'in a future version' - if date is None else ('after %s' % date), instructions + wrapped.__code__.co_filename, 'in a future version' if date is None else + ('after %s' % date), instructions ) ) diff --git a/tensorlayer/distributed.py b/tensorlayer/distributed.py index d95a406e9..800bc5a8f 100644 --- a/tensorlayer/distributed.py +++ b/tensorlayer/distributed.py @@ -398,9 +398,9 @@ def create_task_spec_def(): task_data = env.get('task', None) or {'type': 'master', 'index': 0} cluster_data = env.get('cluster', None) or {'ps': None, 'worker': None, 'master': None} return TaskSpecDef( - task_type=task_data['type'], index=task_data['index'], trial=task_data['trial'] if 'trial' in task_data else - None, ps_hosts=cluster_data['ps'], worker_hosts=cluster_data['worker'], master=cluster_data['master'] - if 'master' in cluster_data else None + task_type=task_data['type'], index=task_data['index'], + trial=task_data['trial'] if 'trial' in task_data else None, ps_hosts=cluster_data['ps'], + worker_hosts=cluster_data['worker'], master=cluster_data['master'] if 'master' in cluster_data else None ) elif 'JOB_NAME' in os.environ: # JOB_NAME, TASK_INDEX, PS_HOSTS, WORKER_HOSTS and MASTER_HOST are used in TensorPort diff --git a/tensorlayer/files/dataset_loaders/mpii_dataset.py b/tensorlayer/files/dataset_loaders/mpii_dataset.py index fd29028e6..69fa228a0 100644 --- a/tensorlayer/files/dataset_loaders/mpii_dataset.py +++ b/tensorlayer/files/dataset_loaders/mpii_dataset.py @@ -157,7 +157,7 @@ def save_joints(): vis = None # if len(joint_pos) == 16: - if ((is_16_pos_only == True) and (len(joint_pos) == 16)) or (is_16_pos_only == False): + if ((is_16_pos_only ==True) and (len(joint_pos) == 16)) or (is_16_pos_only == False): # only use image with 16 key points / or use all data = { 'filename': img_fn, diff --git a/tensorlayer/files/utils.py b/tensorlayer/files/utils.py index 4cd42eeee..8e6aa213d 100644 --- a/tensorlayer/files/utils.py +++ b/tensorlayer/files/utils.py @@ -1462,7 +1462,7 @@ def save_joints(): vis = None # if len(joint_pos) == 16: - if ((is_16_pos_only == True) and (len(joint_pos) == 16)) or (is_16_pos_only == False): + if ((is_16_pos_only ==True) and (len(joint_pos) == 16)) or (is_16_pos_only == False): # only use image with 16 key points / or use all data = { 'filename': img_fn, diff --git a/tensorlayer/iterate.py b/tensorlayer/iterate.py index 807cb2203..6355fc7b4 100644 --- a/tensorlayer/iterate.py +++ b/tensorlayer/iterate.py @@ -65,7 +65,7 @@ def minibatches(inputs=None, targets=None, batch_size=None, allow_dynamic_batch_ excerpt = indices[start_idx:end_idx] else: excerpt = slice(start_idx, end_idx) - if (isinstance(inputs, list) or isinstance(targets, list)) and (shuffle == True): + if (isinstance(inputs, list) or isinstance(targets, list)) and (shuffle ==True): # zsdonghao: for list indexing when shuffle==True yield [inputs[i] for i in excerpt], [targets[i] for i in excerpt] else: diff --git a/tensorlayer/layers/convolution/atrous_conv.py b/tensorlayer/layers/convolution/atrous_conv.py index 71d9a4b06..aab849cac 100644 --- a/tensorlayer/layers/convolution/atrous_conv.py +++ b/tensorlayer/layers/convolution/atrous_conv.py @@ -133,8 +133,8 @@ def __init__( logging.info( "AtrousConv2dLayer %s: n_filter: %d filter_size: %s rate: %d pad: %s act: %s" % ( - self.name, n_filter, filter_size, rate, padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, filter_size, rate, padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) @@ -209,8 +209,8 @@ def __init__( logging.info( "AtrousDeConv2dLayer %s: shape: %s output_shape: %s rate: %d pad: %s act: %s" % ( - self.name, shape, output_shape, rate, padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, shape, output_shape, rate, padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/binary_conv.py b/tensorlayer/layers/convolution/binary_conv.py index 264fbafd7..e00320c2c 100644 --- a/tensorlayer/layers/convolution/binary_conv.py +++ b/tensorlayer/layers/convolution/binary_conv.py @@ -103,8 +103,8 @@ def __init__( logging.info( "BinaryConv2d %s: n_filter: %d filter_size: %s strides: %s pad: %s act: %s" % ( - self.name, n_filter, str(filter_size), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, str(filter_size), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/depthwise_conv.py b/tensorlayer/layers/convolution/depthwise_conv.py index 379f03b9d..bb1efb59e 100644 --- a/tensorlayer/layers/convolution/depthwise_conv.py +++ b/tensorlayer/layers/convolution/depthwise_conv.py @@ -95,8 +95,8 @@ def __init__( logging.info( "DepthwiseConv2d %s: shape: %s strides: %s pad: %s act: %s" % ( - self.name, str(shape), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, str(shape), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/dorefa_conv.py b/tensorlayer/layers/convolution/dorefa_conv.py index 8f4035f13..fab0b5fa2 100644 --- a/tensorlayer/layers/convolution/dorefa_conv.py +++ b/tensorlayer/layers/convolution/dorefa_conv.py @@ -111,8 +111,8 @@ def __init__( logging.info( "DorefaConv2d %s: n_filter: %d filter_size: %s strides: %s pad: %s act: %s" % ( - self.name, n_filter, str(filter_size), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, str(filter_size), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/expert_conv.py b/tensorlayer/layers/convolution/expert_conv.py index d04f24164..d234acef9 100644 --- a/tensorlayer/layers/convolution/expert_conv.py +++ b/tensorlayer/layers/convolution/expert_conv.py @@ -71,8 +71,8 @@ def __init__( logging.info( "Conv1dLayer %s: shape: %s stride: %s pad: %s act: %s" % ( - self.name, str(shape), str(stride), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, str(shape), str(stride), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) @@ -193,8 +193,8 @@ def __init__( logging.info( "Conv2dLayer %s: shape: %s strides: %s pad: %s act: %s" % ( - self.name, str(shape), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, str(shape), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) @@ -281,8 +281,8 @@ def __init__( logging.info( "Conv3dLayer %s: shape: %s strides: %s pad: %s act: %s" % ( - self.name, str(shape), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, str(shape), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/expert_deconv.py b/tensorlayer/layers/convolution/expert_deconv.py index c0f61890c..dbabdd062 100644 --- a/tensorlayer/layers/convolution/expert_deconv.py +++ b/tensorlayer/layers/convolution/expert_deconv.py @@ -113,8 +113,8 @@ def __init__( logging.info( "DeConv2dLayer %s: shape: %s out_shape: %s strides: %s pad: %s act: %s" % ( - self.name, str(shape), str(output_shape), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, str(shape), str(output_shape), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) @@ -196,8 +196,8 @@ def __init__( logging.info( "DeConv3dLayer %s: shape: %s out_shape: %s strides: %s pad: %s act: %s" % ( - self.name, str(shape), str(output_shape), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, str(shape), str(output_shape), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/group_conv.py b/tensorlayer/layers/convolution/group_conv.py index 46f984115..e6a2c7ba9 100644 --- a/tensorlayer/layers/convolution/group_conv.py +++ b/tensorlayer/layers/convolution/group_conv.py @@ -68,8 +68,8 @@ def __init__( logging.info( "GroupConv2d %s: n_filter: %d size: %s strides: %s n_group: %d pad: %s act: %s" % ( - self.name, n_filter, str(filter_size), str(strides), n_group, padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, str(filter_size), str(strides), n_group, padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/quan_conv.py b/tensorlayer/layers/convolution/quan_conv.py index 0b33233dc..ac5805bec 100644 --- a/tensorlayer/layers/convolution/quan_conv.py +++ b/tensorlayer/layers/convolution/quan_conv.py @@ -102,8 +102,8 @@ def __init__( logging.info( "QuanConv2d %s: n_filter: %d filter_size: %s strides: %s pad: %s act: %s" % ( - self.name, n_filter, str(filter_size), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, str(filter_size), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/quan_conv_bn.py b/tensorlayer/layers/convolution/quan_conv_bn.py index be53670fe..1d4569821 100644 --- a/tensorlayer/layers/convolution/quan_conv_bn.py +++ b/tensorlayer/layers/convolution/quan_conv_bn.py @@ -120,8 +120,8 @@ def __init__( logging.info( "QuanConv2dWithBN %s: n_filter: %d filter_size: %s strides: %s pad: %s act: %s " % ( - self.name, n_filter, filter_size, str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, filter_size, str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/separable_conv.py b/tensorlayer/layers/convolution/separable_conv.py index cd838cc20..28168b819 100644 --- a/tensorlayer/layers/convolution/separable_conv.py +++ b/tensorlayer/layers/convolution/separable_conv.py @@ -84,8 +84,8 @@ def __init__( logging.info( "SeparableConv1d %s: n_filter: %d filter_size: %s filter_size: %s depth_multiplier: %d act: %s" % ( - self.name, n_filter, str(filter_size), str(strides), depth_multiplier, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, str(filter_size), str(strides), depth_multiplier, + self.act.__name__ if self.act is not None else 'No Activation' ) ) # with tf.variable_scope(name) as vs: @@ -196,8 +196,8 @@ def __init__( logging.info( "SeparableConv2d %s: n_filter: %d filter_size: %s filter_size: %s depth_multiplier: %d act: %s" % ( - self.name, n_filter, str(filter_size), str(strides), depth_multiplier, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, str(filter_size), str(strides), depth_multiplier, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/simplified_conv.py b/tensorlayer/layers/convolution/simplified_conv.py index b3a03ee21..7581c5fc4 100644 --- a/tensorlayer/layers/convolution/simplified_conv.py +++ b/tensorlayer/layers/convolution/simplified_conv.py @@ -78,8 +78,8 @@ def __init__( logging.info( "Conv1d %s: n_filter: %d filter_size: %s stride: %d pad: %s act: %s dilation_rate: %d" % ( - self.name, n_filter, filter_size, stride, padding, self.act.__name__ - if self.act is not None else 'No Activation', dilation_rate + self.name, n_filter, filter_size, stride, padding, + self.act.__name__ if self.act is not None else 'No Activation', dilation_rate ) ) @@ -183,8 +183,8 @@ def __init__( logging.info( "Conv2d %s: n_filter: %d filter_size: %s strides: %s pad: %s act: %s" % ( - self.name, n_filter, str(filter_size), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, str(filter_size), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) # with tf.variable_scope(name) as vs: diff --git a/tensorlayer/layers/convolution/simplified_deconv.py b/tensorlayer/layers/convolution/simplified_deconv.py index 249aff15a..54437aead 100644 --- a/tensorlayer/layers/convolution/simplified_deconv.py +++ b/tensorlayer/layers/convolution/simplified_deconv.py @@ -77,8 +77,8 @@ def __init__( logging.info( "DeConv2d %s: n_filters: %s strides: %s pad: %s act: %s" % ( - self.name, str(n_filter), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, str(n_filter), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) @@ -149,8 +149,8 @@ def __init__( logging.info( "DeConv3d %s: n_filters: %s strides: %s pad: %s act: %s" % ( - self.name, str(n_filter), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, str(n_filter), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/convolution/ternary_conv.py b/tensorlayer/layers/convolution/ternary_conv.py index fd500c948..ddcc43ad0 100644 --- a/tensorlayer/layers/convolution/ternary_conv.py +++ b/tensorlayer/layers/convolution/ternary_conv.py @@ -104,8 +104,8 @@ def __init__( logging.info( "TernaryConv2d %s: n_filter: %d filter_size: %s strides: %s pad: %s act: %s" % ( - self.name, n_filter, str(filter_size), str(strides), padding, self.act.__name__ - if self.act is not None else 'No Activation' + self.name, n_filter, str(filter_size), str(strides), padding, + self.act.__name__ if self.act is not None else 'No Activation' ) ) diff --git a/tensorlayer/layers/core.py b/tensorlayer/layers/core.py index a93d22966..c2e8145d8 100644 --- a/tensorlayer/layers/core.py +++ b/tensorlayer/layers/core.py @@ -175,9 +175,8 @@ def print_params(self, details=True, session=None): try: val = p.eval(session=session) logging.info( - " param {:3}: {:20} {:15} {} (mean: {:<18}, median: {:<18}, std: {:<18}) ".format( - i, p.name, str(val.shape), p.dtype.name, val.mean(), np.median(val), val.std() - ) + " param {:3}: {:20} {:15} {} (mean: {:<18}, median: {:<18}, std: {:<18}) ". + format(i, p.name, str(val.shape), p.dtype.name, val.mean(), np.median(val), val.std()) ) except Exception as e: logging.info(str(e)) diff --git a/tensorlayer/layers/recurrent.py b/tensorlayer/layers/recurrent.py index 1c4da039f..fad602dd4 100644 --- a/tensorlayer/layers/recurrent.py +++ b/tensorlayer/layers/recurrent.py @@ -1622,9 +1622,9 @@ def __init__( network_decode = DynamicRNNLayer( net_decode_in, cell_fn=cell_fn, cell_init_args=self.cell_init_args, n_hidden=n_hidden, initializer=initializer, - initial_state=(network_encode.final_state if initial_state_decode is None else - initial_state_decode), dropout=dropout, n_layer=n_layer, - sequence_length=decode_sequence_length, return_last=False, return_seq_2d=return_seq_2d, name='decode' + initial_state=(network_encode.final_state if initial_state_decode is None else initial_state_decode), + dropout=dropout, n_layer=n_layer, sequence_length=decode_sequence_length, return_last=False, + return_seq_2d=return_seq_2d, name='decode' ) self.outputs = network_decode.outputs diff --git a/tensorlayer/prepro.py b/tensorlayer/prepro.py index a06bcb7e8..4b9045c78 100644 --- a/tensorlayer/prepro.py +++ b/tensorlayer/prepro.py @@ -1228,10 +1228,10 @@ def rgb_to_hsv(rgb): rc = np.zeros_like(r) gc = np.zeros_like(g) bc = np.zeros_like(b) - rc[mask] = (maxc -r)[mask] / (maxc - minc)[mask] + rc[mask] = (maxc - r)[mask] / (maxc - minc)[mask] gc[mask] = (maxc - g)[mask] / (maxc - minc)[mask] bc[mask] = (maxc - b)[mask] / (maxc - minc)[mask] - hsv[..., 0] = np.select([r== maxc, g == maxc], [bc - gc, 2.0 + rc - bc], default=4.0 + gc - rc) + hsv[..., 0] = np.select([r == maxc, g == maxc], [bc - gc, 2.0 + rc - bc], default=4.0 + gc - rc) hsv[..., 0] = (hsv[..., 0] / 6.0) % 1.0 return hsv @@ -1766,9 +1766,9 @@ def apply_transform(x, transform_matrix, channel_index=2, fill_mode='nearest', c final_affine_matrix = transform_matrix[:2, :2] final_offset = transform_matrix[:2, 2] channel_images = [ - ndi.interpolation.affine_transform( - x_channel, final_affine_matrix, final_offset, order=order, mode=fill_mode, cval=cval - ) for x_channel in x + ndi.interpolation. + affine_transform(x_channel, final_affine_matrix, final_offset, order=order, mode=fill_mode, cval=cval) + for x_channel in x ] x = np.stack(channel_images, axis=0) x = np.rollaxis(x, 0, channel_index + 1) @@ -3114,7 +3114,7 @@ def process_sequences(sequences, end_id=0, pad_val=0, is_shorten=True, remain_en max_length = i_w if remain_end_id is False: seq[i_w] = pad_val # set end_id to pad_val - elif is_end == True: + elif is_end ==True: seq[i_w] = pad_val if remain_end_id is True: diff --git a/tests/test_layers_recurrent.py b/tests/test_layers_recurrent.py index 302ca8255..828f82ff1 100644 --- a/tests/test_layers_recurrent.py +++ b/tests/test_layers_recurrent.py @@ -160,9 +160,9 @@ def setUpClass(cls): rnn = tl.layers.DynamicRNNLayer( nin, cell_fn=tf.contrib.rnn.BasicLSTMCell, n_hidden=cls.embedding_size, - dropout=(cls.keep_prob - if cls.is_train else None), sequence_length=tl.layers.retrieve_seq_length_op2(input_seqs), - return_last=False, return_seq_2d=True, name='dynamicrnn' + dropout=(cls.keep_prob if cls.is_train else None), + sequence_length=tl.layers.retrieve_seq_length_op2(input_seqs), return_last=False, return_seq_2d=True, + name='dynamicrnn' ) net5 = tl.layers.DenseLayer(rnn, n_units=cls.vocab_size, name="o") @@ -182,9 +182,9 @@ def setUpClass(cls): ) rnn = tl.layers.DynamicRNNLayer( nin, cell_fn=tf.contrib.rnn.BasicLSTMCell, n_hidden=cls.embedding_size, - dropout=(cls.keep_prob - if cls.is_train else None), sequence_length=tl.layers.retrieve_seq_length_op2(input_seqs), - n_layer=3, return_last=False, return_seq_2d=True, name='dynamicrnn2' + dropout=(cls.keep_prob if cls.is_train else None), + sequence_length=tl.layers.retrieve_seq_length_op2(input_seqs), n_layer=3, return_last=False, + return_seq_2d=True, name='dynamicrnn2' ) # net6 = tl.layers.DenseLayer(rnn, n_units=cls.vocab_size, name="o2") @@ -229,9 +229,9 @@ def setUpClass(cls): rnn = tl.layers.BiDynamicRNNLayer( nin, cell_fn=tf.contrib.rnn.BasicLSTMCell, n_hidden=cls.embedding_size, - dropout=(cls.keep_prob - if cls.is_train else None), sequence_length=tl.layers.retrieve_seq_length_op2(input_seqs), - return_last=False, return_seq_2d=True, name='bidynamicrnn' + dropout=(cls.keep_prob if cls.is_train else None), + sequence_length=tl.layers.retrieve_seq_length_op2(input_seqs), return_last=False, return_seq_2d=True, + name='bidynamicrnn' ) net9 = tl.layers.DenseLayer(rnn, n_units=cls.vocab_size, name="o4") @@ -248,9 +248,9 @@ def setUpClass(cls): # n_layer=2 rnn = tl.layers.BiDynamicRNNLayer( nin, cell_fn=tf.contrib.rnn.BasicLSTMCell, n_hidden=cls.embedding_size, - dropout=(cls.keep_prob - if cls.is_train else None), sequence_length=tl.layers.retrieve_seq_length_op2(input_seqs), - n_layer=2, return_last=False, return_seq_2d=True, name='bidynamicrnn2' + dropout=(cls.keep_prob if cls.is_train else None), + sequence_length=tl.layers.retrieve_seq_length_op2(input_seqs), n_layer=2, return_last=False, + return_seq_2d=True, name='bidynamicrnn2' ) net10 = tl.layers.DenseLayer(rnn, n_units=cls.vocab_size, name="o5")