                                  Model Immunization from a Condition Number Perspective

(1) [Nonnegativity] For any S ∈ Rpr ×pc , Rill (S) ≥ 0,               of feature covariance matrices, and propose the correspond-
    and Rill (S) = 0 if and only if κ (S) = ∞.                        ing algorithm for model immunization.
                           1          max   2
(2) [Upper Bound] log(κ(S))      ≤ (σS    ) Rill (S), i.e.,           As illustrated in the immunization setup, the feature extrac-
                                 1
    Rill (S) upper bounds log(κ(S)) when σS   max
                                                  is reason-          tor θ is the trainable parameter. For data X ∈ RN ×Din
    ably away from ∞.                                                 of the feature extractor, we analyze the condition number
(3) [Differentiability] If σSmin
                                 = σk < σi for any i < k,             of H(θ) ≜ θ⊤ Kθ ∈ RDin ×Din with rank (H) = k, and
           min
    i.e., σS is unique, then Rill (S) is differentiable and           compact SVD H = U Diag(σ)V ⊤ . Recall, we define
                                                                      K = X ⊤ X to be the covariance matrix of the data.
                               σk uk vk⊤ − k1 S
         ∇S Rill (S) =                           2 .    (13)        In the following theorem, we show that under the same con-
                             1    2   1   min 2                       ditions, the introduced regularizers Rill (·) and Rwell (·)
                            2k ∥S∥F − 2 (σS )
                                                                      are also differentiable w.r.t. θ when applied to θ⊤ Kθ.
                               min                                    Theorem 4.2. For H (θ) = θ⊤ Kθ, if its maximum and
(4) [Monotonic Increase] If σS      is unique, update S
                                                                      minimum singular values σ1 and σk are unique, then
    with ∇S Rill (S) such that S ′ = S − η2 ∇S Rill (S)                                                                 
                                                  2
                                                                       (1) ∇θ Rwell (H (θ)) = 2Kθ σ1 v1 v1⊤ − D1in θ⊤ Kθ ,
                        
                     k     1      2    1    min 2
    for 0 < η2 < k−1      2k ∥S∥  F −  2 (σ S  )     , then
     κ (S ′ ) > κ (S).                                                (2) ∇θ Rill (H (θ)) =
                                                                                                             ⊤
                                                                                                 2Kθ (σk vk vk  1 ⊤
                                                                                                               −k θ Kθ )
                                                                                                                           .
                                                                                                                       2 2
                                                                                                      ∥θ ⊤ Kθ∥2F − 12 σk
                                                                                                 ( 2k
                                                                                                    1
                                                                                                                         )
Proof sketch. We provide some intuitive illustrations of the
proof and defer the complete version to Appendix B.2.                 Proof sketch. The differentiability follows from the same
                                                                      argument of Theorem 4.1 (3) under the condition that the
For (1), as the squared Frobenius norm of a matrix equals             maximum and minimum singular values are unique. The
the sum of the squares of its singular values, the denominator        closed-form gradients are computed with the chain rule in
of Rill (S) is the average of the squared singular values             matrix calculus defined by the Frobenius inner product. The
minus their minimum, ensuring it is nonnegative. It can be            complete proof can be found in Appendix B.3.             □
shown that Rill (S) is inversely related to κ (S), which
indicates that Rill (S) = 0 if and only if κ (S) = ∞.                 With the closed-form gradient of the regularizers w.r.t. θ, we
                                                                      propose our algorithm for model immunization in Alg. 1.
For (2) the upper bound holds by the design of Rill (S)               Specifically, Alg. 1 employs the general gradient descent
and applying the mean value inequality on                             framework. Line 4 conducts standard updates for the clas-
                     
                        max 2
                                            
                                          min 2
                                                                      sifier ω, minimizing the supervised loss L. In lines 5 to 6,
  log κ(S)2 = log (σS
             
                           ) − log σS            . (14)               the regularizers Rill and Rwell are applied on the feature
                         min
                                                                      covariance HH (θ) of the harmful task and HP (θ) of the pre-
For (3), even though σS      is not differentiable since it in-       training task. This is done by updating the feature extractor
volves taking the minimum of the singular values, its sub-            θ with the gradients ∇θ Rill (HH ) and ∇θ Rwell (HP ) nor-
                                                        min
differential is well-defined (Lewis, 1995). When σS          is       malized by their input covariances and the gradient from the
unique, its subdifferential reduces to a singleton, i.e., its         supervised loss ∇θ L.
gradient, making Rill (S) also differentiable.
For (4), one key observation is that the closed-form                  4.3. Condition Number Guarantees
∇S Rill (S) shares the same set of singular vectors as S,
                                                                      We show in the following theorem that the condition number
so that the linear relation in gradient update can be passed
                                                                      decrease/increase guarantees introduced in Theorem A.1 (4)
on to singular values. By choosing a suitable step size, the
                                                                      and Theorem 4.1 (4) are preserved for θ⊤ Kθ even when
increase in condition number can be guaranteed.           □
                                                                      the gradient updates are taken in θ as in Alg. 1, instead of
Theorem 4.1 demonstrates that the regularizer Rill (S) in-            θ⊤ Kθ.
troduced is a reasonable upper bound for maximizing con-              Theorem 4.3. For the trainable feature extractor θ, fea-
dition numbers and indicates that under some mild condi-              ture covariance HP (θ) = θ⊤ KP θ of the primary task
tion, i.e., the minimum singular value is unique, simple              and HH (θ) = θ⊤ KH θ of the immunization task with
first-order algorithms like gradient descent can be used to           rank (HP ) = kP , rank (HH ) = kH and compact SVD
minimize the regularizer with guaranteed increase in condi-           HP (θ) = UP Diag(σP )VP⊤ , HH (θ) = UH Diag(σH )VH⊤ ,
tion number.                                                          for σP = [σP,1 , · · · , σP,kP ], σH = [σH,1 , · · · , σH,kH ],
                                                                              max                   max
                                                                      (1) if σH   is unique, i.e., σH    = σP,1 > σP,2 , update
4.2. Incorporating Regularizers into Immunization                               P
                                                                                        ′
                                                                                                      P
                                                                                                        −1
                                                                          θ such that θ = θ − ηP KP ∇θ Rwell (HP (θ))   for
Given the immunization setup, we now analyze the regular-                                                       √
                                                                                                    1               σP,1 σP,2 −σP,2
izer Rill and Rwell for matrices with the specific structure               0 < ηP < min                     ,           2    2        , then
                                                                                               (1− D1 )σP,1
                                                                                                     in               D σP,2
                                                                                                                        in



                                                                  4
