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

Add unittests & fix some bugs.

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