pymic.loss.cls package
Submodules
pymic.loss.cls.basic module
- class pymic.loss.cls.basic.AbstractClassificationLoss(params=None)
Bases:
ModuleAbstract Classification Loss.
- forward(loss_input_dict)
The arguments should be written in the loss_input_dict dictionary, and it has the following fields.
- Parameters:
prediction – A prediction with shape of [N, C] where C is the class number.
ground_truth – The corresponding ground truth, with shape of [N, 1].
Note that prediction is the digit output of a network, before using softmax.
- class pymic.loss.cls.basic.CrossEntropyLoss(params=None)
Bases:
AbstractClassificationLossStandard Softmax-based CE loss.
- forward(loss_input_dict)
The arguments should be written in the loss_input_dict dictionary, and it has the following fields.
- Parameters:
prediction – A prediction with shape of [N, C] where C is the class number.
ground_truth – The corresponding ground truth, with shape of [N, 1].
Note that prediction is the digit output of a network, before using softmax.
- class pymic.loss.cls.basic.L1Loss(params=None)
Bases:
AbstractClassificationLossL1 (MAE) loss for classification
- forward(loss_input_dict)
The arguments should be written in the loss_input_dict dictionary, and it has the following fields.
- Parameters:
prediction – A prediction with shape of [N, C] where C is the class number.
ground_truth – The corresponding ground truth, with shape of [N, 1].
Note that prediction is the digit output of a network, before using softmax.
- class pymic.loss.cls.basic.MSELoss(params=None)
Bases:
AbstractClassificationLossMean Square Error loss for classification.
- forward(loss_input_dict)
The arguments should be written in the loss_input_dict dictionary, and it has the following fields.
- Parameters:
prediction – A prediction with shape of [N, C] where C is the class number.
ground_truth – The corresponding ground truth, with shape of [N, 1].
Note that prediction is the digit output of a network, before using softmax.
- class pymic.loss.cls.basic.NLLLoss(params=None)
Bases:
AbstractClassificationLossThe negative log likelihood loss for classification.
- forward(loss_input_dict)
The arguments should be written in the loss_input_dict dictionary, and it has the following fields.
- Parameters:
prediction – A prediction with shape of [N, C] where C is the class number.
ground_truth – The corresponding ground truth, with shape of [N, 1].
Note that prediction is the digit output of a network, before using softmax.
- class pymic.loss.cls.basic.SigmoidCELoss(params=None)
Bases:
AbstractClassificationLossSigmoid-based CE loss.
- forward(loss_input_dict)
The arguments should be written in the loss_input_dict dictionary, and it has the following fields.
- Parameters:
prediction – A prediction with shape of [N, C] where C is the class number.
ground_truth – The corresponding ground truth, with shape of [N, 1].
Note that prediction is the digit output of a network, before using softmax.
pymic.loss.cls.util module
- pymic.loss.cls.util.get_soft_label(input_tensor, num_class, data_type='float')
Convert a label tensor to one-hot soft label.
- Parameters:
input_tensor – Tensor with shape of [B, 1].
output_tensor – Tensor with shape of [B, num_class].
num_class – (int) Class number.
data_type – (str) float or double.