Skip to content

fix rnnlm related code style#1283

Merged
danpovey merged 3 commits intokaldi-asr:masterfrom
keli78:rnnlm-fix-style
Jan 15, 2017
Merged

fix rnnlm related code style#1283
danpovey merged 3 commits intokaldi-asr:masterfrom
keli78:rnnlm-fix-style

Conversation

@keli78
Copy link
Contributor

@keli78 keli78 commented Dec 21, 2016

fix rnnlm related code style in Kaldi src/lm/

@danpovey
Copy link
Contributor

danpovey commented Dec 21, 2016 via email

@hainan-xv
Copy link
Contributor

hainan-xv commented Dec 21, 2016 via email

// if (mpos.first != ngrams_.end())
// KALDI_ERR << "Maismatch at index " << mpos.first - ngrams_.begin();
//TODO:auto above requres C++11, and I cannot spell out the type!!!
// TODO: auto above requres C++11, and I cannot spell out the type!!!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is need to change this file

-0.2 <s> a </s>\n\
-0.3 <s> a \xCE\xB2\n\
-0.2 <s> a </s>\n\
\\end\\";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely don't make changes like this - you're changing the behavior of the code by doing this

kRaiseError, ///< Abort on OOV words
kAddToSymbols, ///< Add novel words to the symbol table.
kReplaceWithUnk, ///< Replace OOV words with <unk>.
kReplaceWithUnk, ///< Replace OOV words with <unk>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very sure about this, but I think there should be a space after the comment // thing?

//this is bad
// this is good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just followed the rule "two spaces between code and comments". I'll modify it as what you suggested.

#include <string.h>
#include <math.h>
#include "lm/mikolov-rnnlm-lib.h"
#include "util/table-types.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should probably move this also


vocab_hash_size = 100000000;
vocab_hash = (int *)calloc(vocab_hash_size, sizeof(int));
vocab_hash = reinterpret_cast<int *>(calloc(vocab_hash_size, sizeof(int)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danpovey I am not sure about this... it seems we don't really use calloc() much and use new instead. Not sure what is the right thing to do here...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danpovey I think everything is fine except here, which I am not sure of...

real CRnnLM::random(real min, real max) {
return rand()/(real)RAND_MAX*(max-min)+min;
return rand() / (real)RAND_MAX * (max-min) + min;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max - min

for (a = 1; a < bptt + bptt_block; a++) {
bptt_history[a] = 0;
}
for (a = bptt + bptt_block-1; a > 1; a--) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bptt_block - 1

b += vocab[i].cn;
}
for (i = 0; i < vocab_size; i++) {
df+= vocab[i].cn / static_cast<double>(b);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

df +=

Copy link
Contributor

@hainan-xv hainan-xv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good to try to test the code on real data to see if it breaks anything.

@danpovey
Copy link
Contributor

@hainan-xv do you consider this checked and ready to merge?

@danpovey
Copy link
Contributor

danpovey commented Dec 28, 2016 via email

@keli78
Copy link
Contributor Author

keli78 commented Jan 13, 2017

I did a rescoring test using the trained rnnlm (Mikolov's) on eval92 and dev93 (nnet2 online) and the results after rescoring are better than before. So I think the style modifications should not be wrong.
Ke

@hainan-xv
Copy link
Contributor

OK this PR should be ready to merge then.

ngram 1=4\n\
ngram 2=2\n\
ngram 3=2\n\
ngram 1 = 4\n\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should revert these changes.... the rules don't apply inside strings (would be surprised if cpplint.py noticed this).... and the test code should test the normal arpa format which the old string did.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. will do that soon.

@danpovey danpovey merged commit 1dabfa5 into kaldi-asr:master Jan 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants