3ec1dac0608e511d4cf28e93a3fb908bbabceac5,nn/loss.py,LossFunction,set_loss_type,#LossFunction#Any#,15
Before Change
def set_loss_type(self, type_str):
// TODO raise an error if type_str is not a supported type of loss
// and give support for typo error
if type_str == "CrossEntropy":
self.data_loss_fun = cross_entropy
elif type_str == "Dice":
self.data_loss_fun = dice
elif type_str == "GDSC":
self.data_loss_fun = GDSC_loss
elif type_str == "SensSpec":
self.data_loss_fun = sensitivity_specificity_loss
def set_regularisation_type(self, type_str):
if type_str == "L2":
self.reg_loss_fun = l2_reg_loss
After Change
"Dice": dice,
"GDSC": GDSC_loss,
"SensSpec": sensitivity_specificity_loss}
if type_str in accepted_functions.keys():
self.data_loss_fun = accepted_functions[type_str]
else:
edit_distances = {}
for loss_name in accepted_functions.keys():
edit_distance = damerau_levenshtein_distance(loss_name, type_str)
if edit_distance <= 2:
edit_distances[loss_name] = edit_distance
if edit_distances:
guess_at_correct_spelling = min(edit_distances, key=edit_distances.get)
raise ValueError(("By "{0}", did you mean "{1}"?\n "
""{0}" is not a valid loss.").format(type_str, guess_at_correct_spelling))
else:
raise ValueError("Loss type "%s" is not found." % type_str)
// if type_str == "CrossEntropy":
// self.data_loss_fun = cross_entropy
// elif type_str == "Dice":
// self.data_loss_fun = dice
// elif type_str == "GDSC":
// self.data_loss_fun = GDSC_loss
// elif type_str == "SensSpec":
// self.data_loss_fun = sensitivity_specificity_loss
def set_regularisation_type(self, type_str):
if type_str == "L2":
self.reg_loss_fun = l2_reg_loss
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances
Project Name: NifTK/NiftyNet
Commit Name: 3ec1dac0608e511d4cf28e93a3fb908bbabceac5
Time: 2017-04-26
Author: z.eaton-rosen@ucl.ac.uk
File Name: nn/loss.py
Class Name: LossFunction
Method Name: set_loss_type
Project Name: tensorlayer/tensorlayer
Commit Name: 23a41cfcac5976cab47133fed2f6f53d061e9173
Time: 2019-01-16
Author: dhsig552@163.com
File Name: tensorlayer/layers/core.py
Class Name: Layer
Method Name: __init__
Project Name: microsoft/nni
Commit Name: a850be48e6de9afdb04a0dab0c7facda871f623d
Time: 2019-04-28
Author: purityfan@163.com
File Name: src/sdk/pynni/nni/hyperopt_tuner/hyperopt_tuner.py
Class Name:
Method Name: _split_index