CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

EXCEPTION occurred: The training criterion is not a number (NAN)

Open minghuaiping opened this issue 10 years ago • 2 comments

I'm trying multitask-learning and encountered a problem. The messages are as follow:

Starting minibatch loop. Epoch[ 1 of 200]-Minibatch[ 1- 10]: SamplesSeen = 1000; TrainLossPerSample = nan; TotalTime = 0.9208s; SamplesPerSecond = 1086.0

[CALL STACK] /home/hlt/CNTK/build/release/bin/../lib/libcntkmath.so ( Microsoft::MSR::CNTK::ExceptionWithCallStackstd::runtime_error::CollectCallStack(std::function<void (std::string)> const&, std::function<void ()> const&) + 0x101 ) [0x7f198a6899a1] /home/hlt/CNTK/build/release/bin/../lib/libcntkmath.so ( Microsoft::MSR::CNTK::ExceptionWithCallStackstd::runtime_error::PrintCallStack() + 0x88 ) [0x7f198a689e38] cntk ( void Microsoft::MSR::CNTK::ThrowFormattedstd::runtime_error(char const_, ...) + 0xe2 ) [0x541fd2] cntk ( Microsoft::MSR::CNTK::SGD::TrainOneEpoch(std::shared_ptrMicrosoft::MSR::CNTK::ComputationNetwork, std::shared_ptrMicrosoft::MSR::CNTK::ComputationNetwork, std::shared_ptrMicrosoft::MSR::CNTK::ComputationNodeBase const&, int, unsigned long, Microsoft::MSR::CNTK::IDataReader, double, unsigned long, std::vectorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase, std::allocatorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase > > const&, std::vectorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase, std::allocatorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase > > const&, std::vectorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase, std::allocatorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase > > const&, std::vectorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase, std::allocatorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase > > const&, std::map<std::basic_string<wchar_t, s cntk ( Microsoft::MSR::CNTK::SGD::TrainOrAdaptModel(int, std::shared_ptrMicrosoft::MSR::CNTK::ComputationNetwork, bool, std::shared_ptrMicrosoft::MSR::CNTK::ComputationNetwork, std::shared_ptrMicrosoft::MSR::CNTK::ComputationNodeBase, Microsoft::MSR::CNTK::IDataReader, Microsoft::MSR::CNTK::IDataReader) + 0x1218) [0x72bbb8] cntk ( Microsoft::MSR::CNTK::SGD::Train(std::functionstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNetwork (int)>, int, Microsoft::MSR::CNTK::IDataReader, Microsoft::MSR::CNTK::IDataReader_, bool) + 0x424 ) [0x72da04] cntk ( void DoTrain<Microsoft::MSR::CNTK::ConfigParameters, float>(Microsoft::MSR::CNTK::ConfigParameters const&) + 0x22c ) [0x7497ec] cntk ( void DoCommands(Microsoft::MSR::CNTK::ConfigParameters const&) + 0x804 ) [0x597ec4] cntk ( wmainOldCNTKConfig(int, wchar_t**) + 0x909 ) [0x53b929] cntk ( wmain1(int, wchar_t**) + 0x70 ) [0x53bf80] cntk ( main + 0xd8 ) [0x530bf8] /lib/x86_64-linux-gnu/libc.so.6 ( __libc_start_main + 0xf5 ) [0x7f19892e8ec5] cntk ( ) [0x5349c4] EXCEPTION occurred: The training criterion is not a number (NAN).

minghuaiping avatar Apr 15 '16 11:04 minghuaiping

This usually means your model is not stable (e.g., if you have exp node the value may explode), the learning rate is too high (and thus the model parameters become too big), or the interpolation between two criteria is not right (e.g., the weight is set not considering the different value range of each criterion).

dongyu888 avatar Apr 15 '16 17:04 dongyu888

@dongyu888 Thank you very much! I figured out the reason. It is because there are NAN in my training data.

minghuaiping avatar Apr 16 '16 02:04 minghuaiping