Skip to content

Commit a59e457

Browse files
authored
Merge branch 'master' into make
2 parents 47a1234 + 88d2396 commit a59e457

25 files changed

+149
-100
lines changed

example/tutorial_bipedalwalker_a3c_continuous_action.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
"""
3333

3434
import multiprocessing
35-
import os
36-
import shutil
3735
import threading
3836

3937
import gym
@@ -257,8 +255,7 @@ def work(self):
257255
# start TF threading
258256
worker_threads = []
259257
for worker in workers:
260-
job = lambda: worker.work()
261-
t = threading.Thread(target=job)
258+
t = threading.Thread(target=worker.work)
262259
t.start()
263260
worker_threads.append(t)
264261
COORD.join(worker_threads)

example/tutorial_cifar10_tfrecord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import io
4343
import os
4444
import time
45-
import numpy as np
45+
# import numpy as np
4646
import tensorflow as tf
4747
import tensorlayer as tl
4848
from PIL import Image

example/tutorial_imdb_fasttext.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/env python
2+
"""
3+
This demo implements FastText[1] for sentence classification.
24
3-
__doc__ = """
4-
5-
This demo implements FastText[1] for sentence classification. FastText is a
6-
simple model for text classification with performance often close to
7-
state-of-the-art, and is useful as a solid baseline.
5+
FastText is a simple model for text classification with performance often close
6+
to state-of-the-art, and is useful as a solid baseline.
87
98
There are some important differences between this implementation and what
109
is described in the paper. Instead of Hogwild! SGD[2], we use Adam optimizer

example/tutorial_inceptionV3_tfslim.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def load_image(path):
4646
# load image
4747
img = skimage.io.imread(path)
4848
img = img / 255.0
49-
assert (0 <= img).all() and (img <= 1.0).all()
49+
if ((0 <= img).all() and (img <= 1.0).all()) is False:
50+
raise Exception("image value should be [0, 1]")
5051
# print "Original Image Shape: ", img.shape
5152
# we crop image from center
5253
short_edge = min(img.shape[:2])

example/tutorial_matrix.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import tensorflow as tf
2-
import tensorlayer as tl
32

43
sess = tf.InteractiveSession()
54

example/tutorial_ptb_lstm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
import numpy as np
105105
import tensorflow as tf
106106
import tensorlayer as tl
107-
from tensorlayer.layers import set_keep
108107

109108
flags = tf.flags
110109
flags.DEFINE_string("model", "small", "A type of model. Possible options are: small, medium, large.")

example/tutorial_vgg16.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def conv_layers(net_in):
166166

167167

168168
def conv_layers_simple_api(net_in):
169-
with tf.name_scope('preprocess') as scope:
169+
with tf.name_scope('preprocess'):
170170
"""
171171
Notice that we include a preprocessing layer that takes the RGB image
172172
with pixels values in the range of 0-255 and subtracts the mean image

tensorlayer/db.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,16 @@ def __init__(self, ip='localhost', port=27017, db_name='db_name', user_name=None
8585
self.db_name = db_name
8686
self.user_name = user_name
8787

88+
@classmethod
8889
def __autofill(self, args):
8990
return args.update({'studyID': self.studyID})
9091

91-
def __serialization(self, ps):
92+
@staticmethod
93+
def __serialization(ps):
9294
return pickle.dumps(ps, protocol=2)
9395

94-
def __deserialization(self, ps):
96+
@staticmethod
97+
def __deserialization(ps):
9598
return pickle.loads(ps)
9699

97100
def save_params(self, params=None, args=None): #, file_name='parameters'):
@@ -298,20 +301,25 @@ def test_log(self, args=None):
298301
return _result
299302

300303
@AutoFill
301-
def del_test_log(self, args={}):
304+
def del_test_log(self, args=None):
302305
""" Delete test log.
303306
304307
Parameters
305308
-----------
306309
args : dictionary, find items to delete, leave it empty to delete all log.
307310
"""
311+
if args is None:
312+
args = {}
308313

309314
self.db.TestLog.delete_many(args)
310315
print("[TensorDB] Delete TestLog SUCCESS")
311316

312-
## =========================== Network Architecture ================== ##
317+
# =========================== Network Architecture ================== ##
313318
@AutoFill
314-
def save_model_architecture(self, s, args={}):
319+
def save_model_architecture(self, s, args=None):
320+
if args is None:
321+
args = {}
322+
315323
self.__autofill(args)
316324
fid = self.archfs.put(s, filename="modelarchitecture")
317325
args.update({"fid": fid})

tensorlayer/files.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def load_flickr25k_dataset(tag='sky', path="data", n_threads=50, printable=False
594594
else:
595595
logging.info("[Flickr25k] reading images with tag: {}".format(tag))
596596
images_list = []
597-
for idx in range(0, len(path_tags)):
597+
for idx, _v in enumerate(path_tags):
598598
tags = read_file(folder_tags + '/' + path_tags[idx]).split('\n')
599599
# logging.info(idx+1, tags)
600600
if tag is None or tag in tags:
@@ -1459,6 +1459,13 @@ def load_ckpt(sess=None, mode_name='model.ckpt', save_dir='checkpoint', var_list
14591459
def save_any_to_npy(save_dict={}, name='file.npy'):
14601460
"""Save variables to `.npy` file.
14611461
1462+
Parameters
1463+
------------
1464+
save_dict : directory
1465+
The variables to be saved.
1466+
name : str
1467+
File name.
1468+
14621469
Examples
14631470
---------
14641471
>>> tl.files.save_any_to_npy(save_dict={'data': ['a','b']}, name='test.npy')
@@ -1467,12 +1474,21 @@ def save_any_to_npy(save_dict={}, name='file.npy'):
14671474
... {'data': ['a','b']}
14681475
14691476
"""
1477+
if save_dict is None:
1478+
save_dict = {}
14701479
np.save(name, save_dict)
14711480

14721481

14731482
def load_npy_to_any(path='', name='file.npy'):
14741483
"""Load `.npy` file.
14751484
1485+
Parameters
1486+
------------
1487+
path : str
1488+
Path to the file (optional).
1489+
name : str
1490+
File name.
1491+
14761492
Examples
14771493
---------
14781494
- see tl.files.save_any_to_npy()

tensorlayer/layers/convolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def __init__(
302302
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,
303303
act.__name__))
304304
# logging.info(" DeConv2dLayer: Untested")
305-
with tf.variable_scope(name) as vs:
305+
with tf.variable_scope(name):
306306
W = tf.get_variable(name='W_deconv2d', shape=shape, initializer=W_init, dtype=D_TYPE, **W_init_args)
307307
if b_init:
308308
b = tf.get_variable(name='b_deconv2d', shape=(shape[-2]), initializer=b_init, dtype=D_TYPE, **b_init_args)

0 commit comments

Comments
 (0)