我遇到此运行时错误,我不知道该怎么办。我正在使用基于链接器的其他目的的代码。 https://github.com/oyam/Semantic-Segmentation-using-Adversarial-Networks
过去,我从变量声明中删除了volatile关键字。例子
loss = F.softmax_cross_entropy(self.y_real,Variable(self.xp.ones(batchsize,dtype = self.xp.int32),volatile = not self.gen.train))
到
loss = F.softmax_cross_entropy(self.y_real,Variable(self.xp.ones(batchsize,dtype = self.xp.int32)))
并将Train = true添加到全局配置。 这会造成问题吗?
代码生成运行时错误:
def _fast_hist(label_true, label_pred, n_class):
mask = (label_true >= 0) & (label_true < n_class)
hist = np.bincount(
n_class * label_true[mask].astype(int) +
label_pred[mask], minlength=n_class**2).reshape(n_class, n_class)
return hist
def label_accuracy_score(label_true, label_pred, n_class):
"""Returns accuracy score evaluation result.
- overall accuracy
- mean accuracy
- mean IU
- fwavacc
"""
hist = _fast_hist(label_true.flatten(), label_pred.flatten(), n_class)
acc = np.diag(hist).sum() / hist.sum()
acc_cls = np.diag(hist) / hist.sum(axis=1)
acc_cls = np.nanmean(acc_cls)
iu = np.diag(hist) / (hist.sum(axis=1) + hist.sum(axis=0) -np.diag(hist))
mean_iu = np.nanmean(iu)
freq = hist.sum(axis=1) / hist.sum()
fwavacc = (freq[freq > 0] * iu[freq > 0]).sum()
return acc, acc_cls, mean_iu, fwavacc
我遇到此运行时错误:
/ content / drive /我的驱动器/chainer_version/segmentation/utils.py:195:RuntimeWarning:在long_scalars中遇到无效值 acc = np.diag(hist).sum()/ hist.sum()
/ content / drive /我的驱动器/chainer_version/segmentation/utils.py:196:RuntimeWarning:在true_divide中遇到无效值 acc_cls = np.diag(hist)/ hist.sum(axis = 1)
/ content / drive /我的驱动器/chainer_version/segmentation/utils.py:197:RuntimeWarning:空片的平均值 acc_cls = np.nanmean(acc_cls)
/ content / drive /我的驱动器/chainer_version/segmentation/utils.py:198:RuntimeWarning:true_divide中遇到无效值 iu = np.diag(hist)/(hist.sum(axis = 1)+ hist.sum(axis = 0)-np.diag(hist))
/ content / drive /我的驱动器/chainer_version/segmentation/utils.py:199:RuntimeWarning:空片的平均值 mean_iu = np.nanmean(iu)
/ content / drive /我的驱动器/chainer_version/segmentation/utils.py:200:RuntimeWarning:true_divide中遇到无效值 freq = hist.sum(axis = 1)/ hist.sum()
/ content / drive /我的驱动器/chainer_version/segmentation/utils.py:201:RuntimeWarning:在更大的范围内遇到无效的值 fwavacc =(freq [freq> 0] * iu [freq> 0])。sum()