Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With a zero gradient always reset #384

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/inner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,7 @@ static inline bool isFixedTheta(int m) {
return true; // here the parameter is fixed
}

static inline bool thetaReset0() {
static inline bool thetaReset0(bool forceReset = false) {
NumericVector thetaIni(op_focei.ntheta);
NumericVector thetaUp(op_focei.ntheta);
NumericVector thetaDown(op_focei.ntheta);
Expand Down Expand Up @@ -1985,7 +1985,9 @@ static inline bool thetaReset0() {
adjustEta[ii] = false;
}
}
if (!doAdjust) return false;
if (!doAdjust && !forceReset) {
return false;
}

arma::mat etaMat(rx->nsub, op_focei.neta);
for (int ii = rx->nsub; ii--;){
Expand Down Expand Up @@ -2028,7 +2030,7 @@ void thetaReset(double size){
}

void thetaResetZero() {
thetaReset0();
thetaReset0(true);
warning(_("thetas were reset during optimization because of a zero gradient"));
stop("theta reset0");
}
Expand Down