提交 0b478e99 编写于 作者: C caoying03

follow comments.

上级 faa4da48
...@@ -14,6 +14,7 @@ limitations under the License. */ ...@@ -14,6 +14,7 @@ limitations under the License. */
#include "Evaluator.h" #include "Evaluator.h"
#include "paddle/gserver/gradientmachines/NeuralNetwork.h" #include "paddle/gserver/gradientmachines/NeuralNetwork.h"
#include "paddle/utils/StringUtil.h"
namespace paddle { namespace paddle {
...@@ -259,7 +260,7 @@ public: ...@@ -259,7 +260,7 @@ public:
virtual void printStats(std::ostream& os) const { virtual void printStats(std::ostream& os) const {
storeLocalValues(); storeLocalValues();
os << config_.name() << "=" << evalResults_["error"]; os << config_.name() << " error = " << evalResults_["error"];
os << " deletions error = " << evalResults_["deletion_error"]; os << " deletions error = " << evalResults_["deletion_error"];
os << " insertions error = " << evalResults_["insertion_error"]; os << " insertions error = " << evalResults_["insertion_error"];
os << " substitution error = " << evalResults_["substitution_error"]; os << " substitution error = " << evalResults_["substitution_error"];
...@@ -293,12 +294,10 @@ public: ...@@ -293,12 +294,10 @@ public:
real getValue(const std::string& name, Error* err) const { real getValue(const std::string& name, Error* err) const {
storeLocalValues(); storeLocalValues();
const std::string delimiter("."); std::vector<std::string> buffers;
std::string::size_type foundPos = name.find(delimiter, 0); paddle::str::split(name, '.', &buffers);
CHECK(foundPos != std::string::npos); auto it = evalResults_.find(buffers[buffers.size() - 1]);
auto it = evalResults_.find(
name.substr(foundPos + delimiter.size(), name.length()));
if (it == evalResults_.end()) { if (it == evalResults_.end()) {
*err = Error("Evaluator does not have the key %s", name.c_str()); *err = Error("Evaluator does not have the key %s", name.c_str());
return 0.0f; return 0.0f;
...@@ -307,7 +306,11 @@ public: ...@@ -307,7 +306,11 @@ public:
return it->second; return it->second;
} }
std::string getTypeImpl() const { return "ctc_edit_distance"; } std::string getType(const std::string& name, Error* err) const {
getValue(name, err);
if (!err->isOK()) return "";
return "ctc_edit_distance";
}
}; };
REGISTER_EVALUATOR(ctc_edit_distance, CTCErrorEvaluator); REGISTER_EVALUATOR(ctc_edit_distance, CTCErrorEvaluator);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册