I am running language modeling with "trainingCriterion=crossEntropyWithSoftmax" in the config file. An exception occurred : "NotifyFunctionValuesMBSizeModified: labels InputValue operation had its row dimension 10000 changed by the reader to 4."
Anybody knows how I could use crossEntropyWithSoftmax instead of classCrossEntropyWithSoftmax in LM? Thanks.
Here is my modification in Examples/Text/PennTreebank/Config/rnn.cntk:
rnnType = "LSTM" # TODO: camelCase
trainingCriterion = "crossEntropyWithSoftmax"
evalCriterion = "crossEntropyWithSoftmax"
Call stack is appended here:
[CALL STACK]
[0x5a9a3b] Microsoft::MSR::CNTK::ComputationNode:: NotifyFunctionValuesMBSizeModified () + 0x40b
[0x647b06] void Microsoft::MSR::CNTK::DataReaderHelpers:: NotifyChangedNodes (std::shared_ptrMicrosoft::MSR::CNTK::ComputationNetwork, Microsoft::MSR::CNTK::StreamMinibatchInputs&) + 0x296
[0x65753b] bool Microsoft::MSR::CNTK::DataReaderHelpers:: GetMinibatchIntoNetwork (Microsoft::MSR::CNTK::IDataReader&, std::shared_ptrMicrosoft::MSR::CNTK::ComputationNetwork, std::shared_ptrMicrosoft::MSR::CNTK::ComputationNodeBase, bool, bool, Microsoft::MSR::CNTK::StreamMinibatchInputs&, unsigned long&, std::shared_ptrMicrosoft::MSR::CNTK::MPIWrapper const&) + 0xab
[0x78a931] 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_ptrMicrosoft::MSR::CNTK::ComputationNodeBase> const&, std::vectorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase,std::allocatorstd::shared_ptrMicrosoft::MSR::CNTK::ComputationNodeBase> const&, std::vectorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase,std::allocatorstd::shared_ptrMicrosoft::MSR::CNTK::ComputationNodeBase> const&, std::vectorstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNodeBase,std::allocatorstd::shared_ptrMicrosoft::MSR::CNTK::ComputationNodeBase> const&, Microsoft::MSR::CNTK::StreamMinibatchInputs_, std::lis[0x790501] 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_) + 0x1461
[0x79287f] Microsoft::MSR::CNTK::SGD:: Train (std::functionstd::shared_ptr<Microsoft::MSR::CNTK::ComputationNetwork (int)>, int, Microsoft::MSR::CNTK::IDataReader_, Microsoft::MSR::CNTK::IDataReader_, bool) + 0x25f
[0x635415] void DoTrain Microsoft::MSR::CNTK::ConfigParameters,float(Microsoft::MSR::CNTK::ConfigParameters const&) + 0x2c5
[0x5fcc40] void DoCommands (Microsoft::MSR::CNTK::ConfigParameters const&, std::shared_ptrMicrosoft::MSR::CNTK::MPIWrapper const&) + 0x960
[0x59be3a] wmainOldCNTKConfig (int, wchar_t**) + 0xc8a
[0x59c5e9] wmain1 (int, wchar_t**) + 0x129
[0x5905e8] main + 0x128
[0x7f62653feec5] __libc_start_main + 0xf5
[0x594424]
EXCEPTION occurred: NotifyFunctionValuesMBSizeModified: labels InputValue operation had its row dimension 10000 changed by the reader to 4.
This normally means that the sample dimensions mismatch between the network description and the reader. My guess is that the network specified a 10000-dim one-hot vector for labels, but the reader provides an outdated 4-component index format that is used for class LMs.
@dongyu888, do you know how to correctly specify this?
I only have limited knowledge on this reader.
@frankseide @dongyu888 , do you have an example to train a vanilla language model on PTB using LSTM? It'd be an easier starting point for potential users.
P.S. Frank long time no see. And CNTK is awesome!
Under gitbub source tree, you can find Examples\Text\PennTreebank. You can find the class-based RNN LM example. I think you can make class to be 1 to behave as simple LM.
Thanks! How about NCE? I see the code is there. @dongyu888
@dongyu888 Thanks for the suggestions. I changed to "confClassSize = 1", but it still has the same error. It looks like the reader changed the matrix row to 4: I printed out the row and col info of this line:
https://github.com/Microsoft/CNTK/blob/540cd0be04607534be1df99a64facf893ff5a6eb/Source/ComputationNetworkLib/ComputationNode.h#L1010
Here is the matrix shape info:
GetSampleMatrixNumRows():10000 GetSampleMatrixNumCols():119
Value().GetNumRows():4 Value().GetNumCols():119
@byzhang NCECrossEntropyWithSoftmax seems not supported in LM yet.
So that reader always generate inputs for class based LM training then.