72f89ffbeaad419cad9abc7c2d6a68bc1304396c,torchsample/modules/_utils.py,,validate_optimizer_input,#Any#,34
Before Change
def validate_optimizer_input(optimizer):
if isinstance(optimizer, str):
try:
optimizer = eval("optim.%s" % optimizer)
except:
raise ValueError("Invalid optimizer string input - must match torch function exactly!")
return optimizer
elif hasattr(optimizer, "step") and hasattr(optimizer, "zero_grad"):
return optimizer
else:
raise ValueError("Invalid optimizer input")
After Change
def validate_optimizer_input(optimizer):
dir_optim = dir(optim)
opts = [o.lower() for o in dir_optim]
if isinstance(optimizer, str):
try:
str_idx = opts.index(optimizer.lower())
except:
raise ValueError("Invalid optimizer string input - must match pytorch function.")
return getattr(optim, dir_optim[str_idx])
elif hasattr(optimizer, "step") and hasattr(optimizer, "zero_grad"):
return optimizer
else:
raise ValueError("Invalid optimizer input")
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 10
Instances
Project Name: ncullen93/torchsample
Commit Name: 72f89ffbeaad419cad9abc7c2d6a68bc1304396c
Time: 2017-04-28
Author: ncullen@modv-vlan533.0527.apn.wlan.wireless-pennnet.upenn.edu
File Name: torchsample/modules/_utils.py
Class Name:
Method Name: validate_optimizer_input
Project Name: NeuromorphicProcessorProject/snn_toolbox
Commit Name: 9a062c6473109dfdd545d1db84f62b5037c53128
Time: 2017-06-13
Author: bodo.rueckauer@gmail.com
File Name: snntoolbox/model_libs/caffe_input_lib.py
Class Name: ModelParser
Method Name: get_outbound_layers
Project Name: ncullen93/torchsample
Commit Name: 72f89ffbeaad419cad9abc7c2d6a68bc1304396c
Time: 2017-04-28
Author: ncullen@modv-vlan533.0527.apn.wlan.wireless-pennnet.upenn.edu
File Name: torchsample/modules/_utils.py
Class Name:
Method Name: validate_loss_input