def __init__(self, use_cudnn=True, normalize=True, cache_score=True,
class_weight=None, ignore_label=-1, reduce='mean'):
self.use_cudnn = use_cudnn
self.normalize = normalize
self.cache_score = cache_score
self.class_weight = class_weight
if class_weight is not None:
if self.class_weight.ndim != 1:
raise ValueError('class_weight.ndim should be 1')
if self.class_weight.dtype.kind != 'f':
raise ValueError('The dtype of class_weight should be \'f\'')
if isinstance(self.class_weight, chainer.Variable):
raise ValueError('class_weight should be a numpy.ndarray or '
'cupy.ndarray, not a chainer.Variable')
self.ignore_label = ignore_label
if reduce not in ('mean', 'no'):
raise ValueError(
"only 'mean' and 'no' are valid for 'reduce', but '%s' is "
'given' % reduce)
self.reduce = reduce
评论列表
文章目录