CNTK
CNTK copied to clipboard
EXCEPTION occurred: cannot open word class file
hi, all, while running classbased LM trainning with LSTM, I have found that if define writeWordAndClass section as blow
writeWordAndClassInfo = [
action = "writeWordAndClass"
# input train data
inputFile = "$DataDir$/$trainFile$"
# four column vocabulary file
#
# FORMAT:
# - the first column is the word id
# - the second column is the count of the word
# - the third column is the word
# - the fourth column is the class id
outputVocabFile = "$ModelDir$/vocab.txt"
if outputVocabFile's parent directory(eg, $ModelDir$) doesn't exist, will failed to create vocabulary file, the error message is sth like this:
EXCEPTION occurred: cannot open word class file
SOLUTION: just one more line code can fix this problem, modify Source/ActionsLib/OtherActions.cpp, funtion DoWriteWordAndClassInfo(const ConfigParameters& config), around line 431, change from:
std::ofstream ofvocab;
ofvocab.open(outputVocabFile.c_str());
to
std::ofstream ofvocab;
msra::files::make_intermediate_dirs(s2ws(outputVocabFile));
ofvocab.open(outputVocabFile.c_str());
recomiple and install cntk, then all'll be well, that's all
thanks. will update the code.
this was merged into master