本文整理汇总了C++中DataProvider::getToken方法的典型用法代码示例。如果您正苦于以下问题:C++ DataProvider::getToken方法的具体用法?C++ DataProvider::getToken怎么用?C++ DataProvider::getToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataProvider
的用法示例。
在下文中一共展示了DataProvider::getToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: train
void Rnn::train(DataProvider& dp,
bool doTrain,
double& seconds,
double& wordEntropy,
double& charEntropy,
int& nChars) {
dp.initIterator();
int nWords = dp.getNumTokens();
wordEntropy = 0.0;
charEntropy = 0.0;
double loss = 0.0;
nChars = 0;
int now = 0;
int next = 0;
std::string nextWord;
auto tic = std::chrono::steady_clock::now();
auto toc = std::chrono::steady_clock::now();
seconds = 0.0;
for (int i=0; i<nWords; i++) {
if ( i%10000 == 0 && i>0 ) {
toc = std::chrono::steady_clock::now();
seconds = std::chrono::duration_cast<std::chrono::milliseconds>
(toc - tic).count() / 1000.0;
if (VERBOSE) {
printf("train=%d token %8d/%8d ", doTrain, i, nWords);
printf("char-entropy=%12.6e ", charEntropy / nChars);
printf("word-entropy=%12.6e ", charEntropy / i);
printf("word-model-entropy=%12.6e ", wordEntropy / i);
printf("loss=%12.6e ", loss);
printf("time=%-8.0f ", seconds);
printf("sec/epoch=%-8.0f ", seconds / i * nWords);
printf("words/sec=%-8.0f ", i / seconds);
printf("chars/sec=%-8.0f ", nChars / seconds);
std::cout << std::endl;
if (doTrain) {
// generate(dp);
}
}
}
dp.getToken(now, next, nextWord);
forward(now, next, nextWord, doTrain, wordEntropy, charEntropy, nChars);
loss = model_.alpha_ * wordEntropy + (1.0 - model_.alpha_) * charEntropy;
}
}