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
raise ValueError("Invalid loss input")
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: 9
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: p2irc/deepplantphenomics
Commit Name: 9466fc343c6ba637e67a7f22e60070308929c2b0
Time: 2020-01-24
Author: dbl599@mail.usask.ca
File Name: deepplantphenomics/loaders.py
Class Name:
Method Name: get_dir_images
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