Update accuracy.py
This commit is contained in:
parent
a7c1bbffae
commit
c61c5634c7
|
|
@ -84,7 +84,7 @@ class Accuracy(EvaluationBase):
|
|||
|
||||
@rearrange_inputs
|
||||
def update(self, *inputs):
|
||||
# 更新本地变量。对于分类任务,如果预测值的索引与标签相匹配,则认为预测结果正确。对于多标签任务,如果预测值与标签相匹配,则认为预测结果正确
|
||||
# 更新本地变量。对于二分类任务,如果预测值的索引与标签相匹配,则认为预测结果正确。对于多标签任务,如果预测值与标签相匹配,则认为预测结果正确
|
||||
"""
|
||||
Updates the local variables. For 'classification', if the index of the maximum of the predict value
|
||||
matches the label, the predict result is correct. For 'multilabel', the predict value match the label,
|
||||
|
|
@ -114,7 +114,7 @@ class Accuracy(EvaluationBase):
|
|||
y_pred = self._convert_data(inputs[0])
|
||||
# 将data型的输入值inputs[1]转换为numpy数组
|
||||
y = self._convert_data(inputs[1])
|
||||
# 根据self._type的值判断是分类任务还是多标签任务
|
||||
# 根据self._type的值判断是二分类任务还是多标签任务
|
||||
if self._type == 'classification' and y_pred.ndim == y.ndim and _check_onehot_data(y):
|
||||
# 对于分类任务,如果y_pred和y的维度相同,并且y是onehot编码的,则将y的维度降低到一个维度
|
||||
y = y.argmax(axis=1)
|
||||
|
|
@ -131,7 +131,7 @@ class Accuracy(EvaluationBase):
|
|||
"classes, but current predicted data contain {} classes, please check your predicted "
|
||||
"value(inputs[0]).".format(self._class_num, y_pred.shape[1]))
|
||||
|
||||
# 根据self._type的值判断是分类任务还是多标签任务
|
||||
# 根据self._type的值判断是二分类任务还是多标签任务
|
||||
if self._type == 'classification':
|
||||
# 对于分类任务,将y_pred的维度降低到一个维度
|
||||
indices = y_pred.argmax(axis=1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue