Skip to content

Commit

Permalink
Fix some PEP8 warnings, 4
Browse files Browse the repository at this point in the history
  • Loading branch information
osmr committed Sep 8, 2018
1 parent e70d442 commit c91fc3e
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion chainer_/models/dpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def get_dpn(num_layers,
inc = incs[i]
channels[i][0] = bws[i] + 3 * inc
for j in range(1, k_sec[i]):
channels[i][j] = channels[i][j-1] + inc
channels[i][j] = channels[i][j - 1] + inc

net = DPN(
channels=channels,
Expand Down
6 changes: 3 additions & 3 deletions chainer_/models/shufflenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def shufflenetv2_wd2(**kwargs):
root : str, default '~/.chainer/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(12.0/29.0), model_name="shufflenetv2_wd2", **kwargs)
return get_shufflenetv2(width_scale=(12.0 / 29.0), model_name="shufflenetv2_wd2", **kwargs)


def shufflenetv2_w1(**kwargs):
Expand Down Expand Up @@ -395,7 +395,7 @@ def shufflenetv2_w2d3(**kwargs):
root : str, default '~/.chainer/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(44.0/29.0), model_name="shufflenetv2_w2d3", **kwargs)
return get_shufflenetv2(width_scale=(44.0 / 29.0), model_name="shufflenetv2_w2d3", **kwargs)


def shufflenetv2_w2(**kwargs):
Expand All @@ -412,7 +412,7 @@ def shufflenetv2_w2(**kwargs):
root : str, default '~/.chainer/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(61.0/29.0), model_name="shufflenetv2_w2", **kwargs)
return get_shufflenetv2(width_scale=(61.0 / 29.0), model_name="shufflenetv2_w2", **kwargs)


def _test():
Expand Down
9 changes: 4 additions & 5 deletions common/env_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def get_pip_versions(package_list,
except (subprocess.CalledProcessError, OSError):
out_text = None
module_versions[module] = out_text

return module_versions


Expand Down Expand Up @@ -91,7 +90,7 @@ def get_pyenv_info(packages,
# get versions from __version__ string
modules_versions = get_package_versions(packages)
pyenv_info.update(modules_versions)

# get versions from pip
if type(pip_packages) == list and len(pip_packages) > 0 and pip_packages[0]:
modules_versions_pip = get_pip_versions(pip_packages, python_version)
Expand All @@ -101,7 +100,7 @@ def get_pyenv_info(packages,
# set python version
try:
pyenv_info["python"] = "{0}.{1}.{2}".format(*sys.version_info[0:3])
except:
except BaseException:
pyenv_info["python"] = "unknown"

if pwd:
Expand All @@ -117,10 +116,10 @@ def get_pyenv_info(packages,
command = ['cd {}; git log -n 1'.format(pyenv_info['pwd'])]
out_bytes = subprocess.check_output(command, shell=True)
out_text = out_bytes.decode('utf-8')
except:
except BaseException:
out_text = 'unknown'
pyenv_info["git"] = out_text.strip()

return pyenv_info


Expand Down
2 changes: 1 addition & 1 deletion gluon/lr_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def update(self, i, epoch):
elif self.warmup_mode == 'linear':
self.learning_rate = self.warmup_lr + (self.base_lr - self.warmup_lr) * T / self.warmup_N
elif self.warmup_mode == 'poly':
self.learning_rate = self.warmup_lr + (self.base_lr - self.warmup_lr) * \
self.learning_rate = self.warmup_lr + (self.base_lr - self.warmup_lr) *\
pow(T / self.warmup_N, self.power)
elif self.warmup_mode == 'cosine':
self.learning_rate = self.warmup_lr + (self.base_lr - self.warmup_lr) *\
Expand Down
2 changes: 1 addition & 1 deletion gluon/models/dpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def get_dpn(num_layers,
inc = incs[i]
channels[i][0] = bws[i] + 3 * inc
for j in range(1, k_sec[i]):
channels[i][j] = channels[i][j-1] + inc
channels[i][j] = channels[i][j - 1] + inc

net = DPN(
channels=channels,
Expand Down
2 changes: 1 addition & 1 deletion gluon/models/mobilenet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
MobileNet & FD-MobileNet, implemented in Gluon.
Original papers:
Original papers:
- 'MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications,'
https://arxiv.org/abs/1704.04861.
- 'FD-MobileNet: Improved MobileNet with A Fast Downsampling Strategy,' https://arxiv.org/abs/1802.03750.
Expand Down
6 changes: 3 additions & 3 deletions gluon/models/shufflenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def shufflenetv2_wd2(**kwargs):
root : str, default '~/.mxnet/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(12.0/29.0), model_name="shufflenetv2_wd2", **kwargs)
return get_shufflenetv2(width_scale=(12.0 / 29.0), model_name="shufflenetv2_wd2", **kwargs)


def shufflenetv2_w1(**kwargs):
Expand Down Expand Up @@ -394,7 +394,7 @@ def shufflenetv2_w2d3(**kwargs):
root : str, default '~/.mxnet/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(44.0/29.0), model_name="shufflenetv2_w2d3", **kwargs)
return get_shufflenetv2(width_scale=(44.0 / 29.0), model_name="shufflenetv2_w2d3", **kwargs)


def shufflenetv2_w2(**kwargs):
Expand All @@ -411,7 +411,7 @@ def shufflenetv2_w2(**kwargs):
root : str, default '~/.mxnet/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(61.0/29.0), model_name="shufflenetv2_w2", **kwargs)
return get_shufflenetv2(width_scale=(61.0 / 29.0), model_name="shufflenetv2_w2", **kwargs)


def _test():
Expand Down
2 changes: 1 addition & 1 deletion gluon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,4 @@ def validate(acc_top1,
acc_top5.update(labels_list, outputs_list)
_, top1 = acc_top1.get()
_, top5 = acc_top5.get()
return 1-top1, 1-top5
return 1.0 - top1, 1.0 - top5
8 changes: 4 additions & 4 deletions pytorch/models/dpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ def __init__(self,
super(DPN, self).__init__()

self.features = DualPathSequential(
return_two=False,
first_ordinals=1,
last_ordinals=0)
return_two=False,
first_ordinals=1,
last_ordinals=0)
self.features.add_module("init_block", DPNInitBlock(
in_channels=in_channels,
out_channels=init_block_channels,
Expand Down Expand Up @@ -510,7 +510,7 @@ def get_dpn(num_layers,
inc = incs[i]
channels[i][0] = bws[i] + 3 * inc
for j in range(1, k_sec[i]):
channels[i][j] = channels[i][j-1] + inc
channels[i][j] = channels[i][j - 1] + inc

net = DPN(
channels=channels,
Expand Down
2 changes: 1 addition & 1 deletion pytorch/models/model_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class requests_failed_to_import(object):
dirname = os.path.dirname(os.path.abspath(os.path.expanduser(fname)))
if not os.path.exists(dirname):
os.makedirs(dirname)
while retries+1 > 0:
while retries + 1 > 0:
# Disable pyling too broad Exception
# pylint: disable=W0703
try:
Expand Down
6 changes: 3 additions & 3 deletions pytorch/models/shufflenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def shufflenetv2_wd2(**kwargs):
root : str, default '~/.torch/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(12.0/29.0), model_name="shufflenetv2_wd2", **kwargs)
return get_shufflenetv2(width_scale=(12.0 / 29.0), model_name="shufflenetv2_wd2", **kwargs)


def shufflenetv2_w1(**kwargs):
Expand Down Expand Up @@ -386,7 +386,7 @@ def shufflenetv2_w2d3(**kwargs):
root : str, default '~/.torch/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(44.0/29.0), model_name="shufflenetv2_w2d3", **kwargs)
return get_shufflenetv2(width_scale=(44.0 / 29.0), model_name="shufflenetv2_w2d3", **kwargs)


def shufflenetv2_w2(**kwargs):
Expand All @@ -401,7 +401,7 @@ def shufflenetv2_w2(**kwargs):
root : str, default '~/.torch/models'
Location for keeping the model parameters.
"""
return get_shufflenetv2(width_scale=(61.0/29.0), model_name="shufflenetv2_w2", **kwargs)
return get_shufflenetv2(width_scale=(61.0 / 29.0), model_name="shufflenetv2_w2", **kwargs)


def _test():
Expand Down
6 changes: 3 additions & 3 deletions pytorch/models/squeezenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def __init__(self,

self.output = nn.Sequential()
self.output.add_module('final_conv', nn.Conv2d(
in_channels=in_channels,
out_channels=num_classes,
kernel_size=1))
in_channels=in_channels,
out_channels=num_classes,
kernel_size=1))
self.output.add_module('final_activ', nn.ReLU(inplace=True))
self.output.add_module('final_pool', nn.AvgPool2d(
kernel_size=13,
Expand Down
2 changes: 1 addition & 1 deletion train_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def main():
batch_size=batch_size,
num_workers=args.num_workers)

num_training_samples = 1281167
# num_training_samples = 1281167
optimizer, lr_scheduler, start_epoch = prepare_trainer(
net=net,
optimizer_name=args.optimizer_name,
Expand Down

0 comments on commit c91fc3e

Please sign in to comment.