Skip to content

Commit ff89160

Browse files
zsdonghaonebulaV
authored andcommitted
Fix unused code (#358)
* remove unused code * static method * remove as vs * remove reimport
1 parent 025e874 commit ff89160

File tree

10 files changed

+13
-17
lines changed

10 files changed

+13
-17
lines changed

example/tutorial_cifar10_tfrecord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# import numpy as np
4646
import tensorflow as tf
4747
import tensorlayer as tl
48-
from PIL import Image
48+
# from PIL import Image
4949
from tensorlayer.layers import *
5050

5151
model_file_name = "model_cifar10_tfrecord.ckpt"

example/tutorial_frozenlake_dqn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
"""
2828

2929
import time
30-
31-
import matplotlib.pyplot as plt
30+
import gym
3231
import numpy as np
3332
import tensorflow as tf
3433
import tensorlayer as tl

example/tutorial_ptb_lstm_state_is_tuple.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
import numpy as np
107107
import tensorflow as tf
108108
import tensorlayer as tl
109-
from tensorlayer.layers import set_keep
110109

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

example/tutorial_vgg16.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@
5050

5151
def conv_layers(net_in):
5252
with tf.name_scope('preprocess'):
53-
"""
54-
Notice that we include a preprocessing layer that takes the RGB image
55-
with pixels values in the range of 0-255 and subtracts the mean image
56-
values (calculated over the entire ImageNet training set).
57-
"""
53+
# Notice that we include a preprocessing layer that takes the RGB image
54+
# with pixels values in the range of 0-255 and subtracts the mean image
55+
# values (calculated over the entire ImageNet training set).
5856
mean = tf.constant([123.68, 116.779, 103.939], dtype=tf.float32, shape=[1, 1, 1, 3], name='img_mean')
5957
net_in.outputs = net_in.outputs - mean
6058

tensorlayer/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ def del_params(self, args=None):
205205

206206
print("[TensorDB] Delete params SUCCESS: {}".format(args))
207207

208-
def _print_dict(self, args):
208+
@staticmethod
209+
def _print_dict(args):
209210
# return " / ".join(str(key) + ": "+ str(value) for key, value in args.items())
210211

211212
string = ''

tensorlayer/files.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ def load_ckpt(sess=None, mode_name='model.ckpt', save_dir='checkpoint', var_list
14561456
logging.info("[*] load ckpt fail ...")
14571457

14581458

1459-
def save_any_to_npy(save_dict={}, name='file.npy'):
1459+
def save_any_to_npy(save_dict=None, name='file.npy'):
14601460
"""Save variables to `.npy` file.
14611461
14621462
Parameters
@@ -1503,8 +1503,7 @@ def load_npy_to_any(path='', name='file.npy'):
15031503
try:
15041504
return npy
15051505
except Exception:
1506-
logging.info("[!] Fail to load %s" % file_path)
1507-
exit()
1506+
raise Exception("[!] Fail to load %s" % file_path)
15081507

15091508

15101509
def file_exists(filepath):

tensorlayer/layers/convolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def __init__(
374374
act = tf.identity
375375
logging.info("Conv3dLayer %s: shape:%s strides:%s pad:%s act:%s" % (self.name, str(shape), str(strides), padding, act.__name__))
376376

377-
with tf.variable_scope(name) as vs:
377+
with tf.variable_scope(name):
378378
# W = tf.Variable(W_init(shape=shape, **W_init_args), name='W_conv')
379379
# b = tf.Variable(b_init(shape=[shape[-1]], **b_init_args), name='b_conv')
380380
W = tf.get_variable(name='W_conv3d', shape=shape, initializer=W_init, dtype=D_TYPE, **W_init_args)

tensorlayer/layers/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ def __init__(
878878
n_in = int(self.inputs.get_shape()[-1])
879879
self.n_units = n_units
880880
logging.info("DenseLayer %s: %d %s" % (self.name, self.n_units, act.__name__))
881-
with tf.variable_scope(name) as vs:
881+
with tf.variable_scope(name):
882882
W = tf.get_variable(name='W', shape=(n_in, n_units), initializer=W_init, dtype=D_TYPE, **W_init_args)
883883
if b_init is not None:
884884
try:

tensorlayer/layers/normalization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def __init__(
138138
update_moving_variance = moving_averages.assign_moving_average(
139139
moving_variance, variance, decay, zero_debias=False) # if zero_debias=True, has bias
140140
# logging.info("TF12 moving")
141-
except Exception as e: # TF11
141+
except Exception: # TF11
142142
update_moving_mean = moving_averages.assign_moving_average(moving_mean, mean, decay)
143143
update_moving_variance = moving_averages.assign_moving_average(moving_variance, variance, decay)
144144
# logging.info("TF11 moving")

tensorlayer/nlp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def build_words_dataset(words=None, vocabulary_size=50000, printable=True, unk_k
652652
"""
653653
if words is None:
654654
raise Exception("words : list of str or byte")
655-
import collections
655+
656656
count = [[unk_key, -1]]
657657
count.extend(collections.Counter(words).most_common(vocabulary_size - 1))
658658
dictionary = dict()

0 commit comments

Comments
 (0)