def error_per_calss(self, y):
"""
Return an array where each value is the error for the corresponding
classe in the minibatch.
:type y: theano.tensor.TensorType
:param y: corresponds to a vector that gives for each example the
correct label.
"""
if y.ndim != self.y_decision.ndim:
raise TypeError("y should have the same shape as self.y_decision",
('y', y.type, "y_decision", self.y_decision.type))
if y.dtype.startswith('int') or y.dtype.startswith('uint'):
y_decision_res = T.neq(self.y_decision, y)
for (i, y_decision_r) in enumerate(y_decision_res):
self.n_classes_seen[y[i]] += 1
if y_decision_r:
self.n_wrong_classif_made[y[i]] += 1
pred_per_class = self.n_wrong_classif_made / self.n_classes_seen
return T.mean(y_decision_res), pred_per_class
else:
raise NotImplementedError()
评论列表
文章目录