Skip to content

correct SAGA weight update with prox #24679

Closed

Description

@NikZak

It seems that saga weights are being updated here with saga bit after the prox operator has been applied to SAG update

weights[f_idx + class_ind] -= \

Should the prox operator be applied again here after SAGA weight update?
Looks like it is what is happeng in lightning implementation

Activity

  1. added
    Needs Triage
    on Oct 17, 2022
  2. ogrisel commented on Oct 18, 2022

    @ogrisel
    Member
  3. ogrisel commented on Nov 17, 2022

    @ogrisel
    Member

    Maybe @agramfort @mblondel or @pierreablin would like to confirm this and someone might want to open a PR with non-regression test if possible?

  4. agramfort commented on Nov 20, 2022

    @agramfort
    Member

    ping @TomDLT

    I don't know this code very well

  5. TomDLT commented on Nov 22, 2022

    @TomDLT
    Member

    This is normal, although the code could be more self-explanatory:

    • In this code, the gradient step is not applied every time the gradient is computed. Indeed, if the data is sparse, the random sample X_i will change the averaged gradient only on features j where X_ij != 0. In some cases, the average gradient on feature j might change only after k random samples with no change. In these cases, instead of applying k times the same gradient step on feature j, we apply the gradient step only once, scaled by k. This is called the "Just-in-time update" (or lagged_update in the code).

    • So the gradient step is performed in lagged_update. This function also applies the prox operator after the weights update. Note that because the lagged update actually performs k gradient steps, we need to apply prox(gradient_step(prox(gradient_step(...)))), which kind of defeats the purpose of the lagged update, but this can be avoided sometimes with a trick actually taken from lightning.

    • For SAGA, there are also these lines, which change the weights outside of the lagged update because it is a term in SAGA that does not depend on the average gradient. The prox is applied later, in the following lagged update, before computing the following prediction.

    • On top of that, the SAG/A update scales down all the weights at each iteration. So to avoid updating all the weights at each iteration, there is a trick to factor out the scaling down, and to only apply it in the lagged update. When the factored-out scale is too small, it is reset for numerical stability, and this reset requires applying all remaining lagged updates.

    • This scale reset is also performed every n_samples iterations before each convergence check, so when the algorithm stops, we are sure that there is no remaining lagged updates.

  6. ogrisel commented on Dec 2, 2022

    @ogrisel
    Member

    @NikZak does this answer your concern?

  7. removed
    Needs Triage
    on Dec 2, 2022
  8. ogrisel commented on Dec 2, 2022

    @ogrisel
    Member

    Maybe someone could open a PR to add some inline comments with either a copy of @TomDLT's comment or a link to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions