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"):
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])
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
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: apache/incubator-mxnet
Commit Name: dfa3d07a74e59297394c624a3373a335f94a64eb
Time: 2019-12-26
Author: xinyu1.chen@intel.com
File Name: example/neural_collaborative_filtering/ncf.py
Class Name:
Method Name:
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