PaddlePaddle运行时出现EnforceNotMet: Enforce failed错误

原创
2019/01/31 17:12
阅读数 2.5K
  • 报错信息
EnforceNotMet: Enforce failed. Expected lbl < class_num, but received lbl:6 >= class_num:6.
 at [/paddle/paddle/fluid/operators/math/cross_entropy.cc:52]
PaddlePaddle Call Stacks: 
0       0x7f39995286b6p paddle::platform::EnforceNotMet::EnforceNotMet(std::__exception_ptr::exception_ptr, char const*, int) + 486
1       0x7f3999fd4d0ep paddle::operators::math::CrossEntropyFunctor<paddle::platform::CPUDeviceContext, float>::operator()(paddle::platform::CPUDeviceContext const&, paddle::framework::Tensor*, paddle::framework::Tensor const*, paddle::framework::Tensor const*, bool, int) + 6190
2       0x7f3999eda038p paddle::operators::CrossEntropyOpKernel<paddle::platform::CPUDeviceContext, float>::Compute(paddle::framework::ExecutionContext const&) const + 472
3       0x7f3999eda1a3p std::_Function_handler<void (paddle::framework::ExecutionContext const&), paddle::framework::OpKernelRegistrarFunctor<paddle::platform::CPUPlace, false, 0ul, paddle::operators::CrossEntropyOpKernel<paddle::platform::CPUDeviceContext, float>, paddle::operators::CrossEntropyOpKernel<paddle::platform::CPUDeviceContext, double> >::operator()(char const*, char const*) const::{lambda(paddle::framework::ExecutionContext const&)#1}>::_M_invoke(std::_Any_data const&, paddle::framework::ExecutionContext const&) + 35
4       0x7f399a0a52ecp paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 492
5       0x7f399a0a171fp paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 255
6       0x7f39995e94eap paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 298
7       0x7f39995e9ee0p paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool) + 128
8       0x7f399950ff5dp
  • 问题复现
def getdata():
    def reader():
        for i in range(len(data_y)):
            yield np.array(data_X[i]).astype('float32'), np.array(data_y[i]).astype('int64')
    return reader
def getdata():
    def reader():
        for i in range(len(data_y)):
            yield np.array(data_X[i]).astype('float32'), np.array(data_y[i]- 3).astype('int64')
    return reader
  • 报错信息
EnforceNotMet: Enforce failed. Expected lbl < class_num, but received lbl:6 >= class_num:6.
 at [/paddle/paddle/fluid/operators/math/cross_entropy.cc:52]
PaddlePaddle Call Stacks: 
0       0x7f39995286b6p paddle::platform::EnforceNotMet::EnforceNotMet(std::__exception_ptr::exception_ptr, char const*, int) + 486
1       0x7f3999fd4d0ep paddle::operators::math::CrossEntropyFunctor<paddle::platform::CPUDeviceContext, float>::operator()(paddle::platform::CPUDeviceContext const&, paddle::framework::Tensor*, paddle::framework::Tensor const*, paddle::framework::Tensor const*, bool, int) + 6190
2       0x7f3999eda038p paddle::operators::CrossEntropyOpKernel<paddle::platform::CPUDeviceContext, float>::Compute(paddle::framework::ExecutionContext const&) const + 472
3       0x7f3999eda1a3p std::_Function_handler<void (paddle::framework::ExecutionContext const&), paddle::framework::OpKernelRegistrarFunctor<paddle::platform::CPUPlace, false, 0ul, paddle::operators::CrossEntropyOpKernel<paddle::platform::CPUDeviceContext, float>, paddle::operators::CrossEntropyOpKernel<paddle::platform::CPUDeviceContext, double> >::operator()(char const*, char const*) const::{lambda(paddle::framework::ExecutionContext const&)#1}>::_M_invoke(std::_Any_data const&, paddle::framework::ExecutionContext const&) + 35
4       0x7f399a0a52ecp paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 492
5       0x7f399a0a171fp paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 255
6       0x7f39995e94eap paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 298
7       0x7f39995e9ee0p paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool) + 128
8       0x7f399950ff5dp
  • 问题复现
def getdata():
    def reader():
        for i in range(len(data_y)):
            yield np.array(data_X[i]).astype('float32'), np.array(data_y[i]).astype('int64')
    return reader
def getdata():
    def reader():
        for i in range(len(data_y)):
            yield np.array(data_X[i]).astype('float32'), np.array(data_y[i]- 3).astype('int64')
    return reader

本文分享 CSDN - 飞桨PaddlePaddle。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部