[PATCH 24/24] [Train:Bugfix] Use input instead of replace for parameter update

This commit is contained in:
xiaying 2020-03-04 20:56:56 +08:00 committed by xiaying
parent 32aea32cd1
commit bae24a62d1
2 changed files with 2 additions and 2 deletions

View File

@ -336,7 +336,7 @@ const std::string& Variable::name() const {
return mFrom->outputName(mFromIndex);
}
bool Variable::input(VARP src) {
if (nullptr != mFrom->get() && VARP::INPUT != mFrom->mType) {
if (nullptr != mFrom->get() || VARP::CONST == mFrom->mType) {
MNN_ERROR("Can't input to no-input op\n");
return false;
}

View File

@ -34,7 +34,7 @@ bool ParameterOptimizer::step(Express::VARP loss) {
iter.second.fix(Express::VARP::TRAINABLE);
}
for (auto iter : res) {
Express::Variable::replace(iter.first, iter.second);
iter.first->input(iter.second);
}
return !res.empty();
}