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

Expose Evaluator's getNames/getValue to SWIG

上级 6415b077
......@@ -33,3 +33,12 @@ std::vector<std::string> Evaluator::getNames() const {
m->rawPtr->getNames(&retv);
return retv;
}
double Evaluator::getValue(const std::string name) const {
paddle::Error err;
double v = m->rawPtr->getValue(name, &err);
if (err) {
throw std::runtime_error(err.msg());
}
return v;
}
......@@ -902,6 +902,8 @@ public:
std::vector<std::string> getNames() const;
double getValue(const std::string name) const;
private:
EvaluatorPrivate* m;
......
......@@ -89,9 +89,14 @@ def main():
except Exception as e:
print e
ev = m.makeEvaluator()
ev.start()
m.forwardBackward(inArgs, outArgs, swig_paddle.PASS_TRAIN,
update_callback)
m.eval(ev)
ev.finish()
for name in ev.getNames():
print name, ev.getValue(name)
for optimizer in optimizers:
optimizer.finishBatch()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册