Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

Check failed: out[j] > 0 && out[j] < 1.0

Open cbstyle opened this issue 8 years ago • 7 comments

I4021 60:38:19.824681 2320 TrainerInternal.cpp:165] Batch=2400 samples=38400 AvgCost=7.79625 CurrentCost=7.06948 Eval: classification_error=0.00887789 CurrentEval: classification_error=0.00827465 ................... I4021 60:41:42.349977 2320 TrainerInternal.cpp:165] Batch=2420 samples=38720 AvgCost=7.79441 CurrentCost=7.57395 Eval: classification_error=0.00888066 CurrentEval: classification_error=0.00921362 ..F0421 06:42:05.695808 2320 Matrix.cpp:3795] # Check failed: out[j] > 0 && out[j] < 1.0 *** Check failure stack trace: *** @ 0xafe2ed google::LogMessage::Fail() @ 0xb01d9c google::LogMessage::SendToLog() @ 0xafdde3 google::LogMessage::Flush() @ 0xb032ae google::LogMessageFatal::~LogMessageFatal() @ 0xe02b52 paddle::CpuMatrix::multiBinaryLabelCrossEntropy() @ 0xc7a52f paddle::MultiBinaryLabelCrossEntropy::forwardImp() @ 0xc76588 paddle::CostLayer::forward() @ 0xb26896 paddle::NeuralNetwork::forward() @ 0xb2a726 paddle::GradientMachine::forwardBackward() @ 0xdabdba paddle::TrainerInternal::forwardBackwardBatch() @ 0xdaa411 paddle::TrainerInternal::trainOneBatch() @ 0xda5a26 paddle::Trainer::trainOneDataBatch() @ 0xda5f2f paddle::Trainer::trainOnePass() @ 0xda4652 paddle::Trainer::train() @ 0xafa224 main @ 0x318ae1ecdd (unknown) @ 0xaf9e5d (unknown)

cbstyle avatar Apr 21 '18 03:04 cbstyle

v1版paddle,单机cpu版,已经train了2k多个batch_size了,为啥报这个错误呢?我输出变量名称是output,这里的out是读数据问题?还是训练过程问题?

cbstyle avatar Apr 21 '18 03:04 cbstyle

这里的out是multiBinaryLabelCrossEntropy的输入,报错信息,是值的范围有误。你这个cost的输入是什么层呢?用的什么激活函数?

qingqing01 avatar Apr 21 '18 03:04 qingqing01

up_proj = fc_layer(input=lstm_pool, size=512, act=ReluActivation(), bias_attr=bias_attr) hidden = fc_layer(input=up_proj, size=256, act=TanhActivation(), bias_attr=bias_attr) output = fc_layer(input=hidden, size=label_size, name='output', bias_attr=bias_attr, act=SoftmaxActivation())

Layer( type = 'multi_binary_label_cross_entropy', name = 'cost', inputs = [Input('output'), Input('label')] )

Evaluator( inputs = ['output', 'label'], type = 'classification_error', name = 'classification_error', classification_threshold = 0.5 )

Outputs('cost')

cbstyle avatar Apr 21 '18 03:04 cbstyle

我理解这里loss的输入用SoftmaxActivation已经做了归一化了,为啥会导致输出范围有问题呢? 这里报错说输出out不在[0-1]之间,怎么产生的呢?

cbstyle avatar Apr 21 '18 03:04 cbstyle

你用SoftmaxActivation时,可能一些维度出现了0,一些出现了1,导致check出错。

multi_binary_label_cross_entropy输入层通常接sigmoid激活函数,假设各个类别相互独立,每个维度上当做一个二分类,评估时和阈值比较。我们在接口里,也给了一些warning信息:

https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/trainer_config_helpers/layers.py#L6421

qingqing01 avatar Apr 21 '18 03:04 qingqing01

1、这里换成SigmoidActivation这个可以吗?对结果影响大吗? 2、这个问题可能是输入数据导致的吗?如果是这样的话,我应该对数据数据进行怎样的检查呢?

cbstyle avatar Apr 21 '18 04:04 cbstyle

  1. 这个和算法、建模有关系,我理解是可以的。
  2. 从计算来看,上面check出错,也可能是数值异常,也可能和输入数据有关。如果是这样,感觉先要确定是否是数值异常。

qingqing01 avatar Apr 21 '18 04:04 qingqing01