提交 11003668 编写于 作者: Y Yu Yang

Add unittests & fix some bugs.

上级 6deb33d9
......@@ -20,7 +20,7 @@ namespace paddle {
/**
* calculate sequence-to-sequence edit distance
*/
class CTCErrorEvaluator : public Evaluator {
class CTCErrorEvaluator : public NotGetableEvaluator {
private:
MatrixPtr outActivations_;
int numTimes_, numClasses_, numSequences_, blank_;
......
......@@ -823,8 +823,10 @@ real PrecisionRecallEvaluator::getValue(const std::string& name,
std::vector<std::string> buffers;
paddle::str::split(name, '.', &buffers);
auto it = this->values_.find(buffers[buffers.size() - 1]);
if (it != this->values_.end() && err != nullptr) {
*err = Error("No such key %s", name.c_str());
if (it == this->values_.end()) { // not found
if (err != nullptr) {
*err = Error("No such key %s", name.c_str());
}
return .0f;
}
......
......@@ -110,6 +110,18 @@ void testEvaluator(TestConfig testConf,
testEvaluator->finish();
LOG(INFO) << *testEvaluator;
std::vector<std::string> names;
testEvaluator->getNames(&names);
paddle::Error err;
for (auto& name : names) {
auto value = testEvaluator->getValueStr(name, &err);
ASSERT_TRUE(err.isOK());
LOG(INFO) << name << " " << value;
auto tp = testEvaluator->getType(name, &err);
ASSERT_TRUE(err.isOK());
ASSERT_EQ(testConf.evaluatorConfig.type(), tp);
}
double totalScore2 = 0.0;
if (testConf.testAccumulate) {
testEvaluator->start();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册