def __init__(self, WA=1, WS=1, slack=0.1, max_stride=100):
    'Helper class to compute the Lipschitz constants of grad f.\n\n        The __call__ function compute the spectral norms of A or S, which\n        determine the Lipschitz constant of the respective update steps.\n\n        If a weight matrix is used, the stepsize will be upper bounded by\n        assuming the maximum value of the weights. In the case of varying\n        weights, it is generally advised to normalize the weight matrix\n        differently for the A and S updates, therefore two maximum numbers\n        (WAMax, WSmax) can be set.\n\n        Because the spectral norm is expensive to compute, it will only update\n        the step_size if relative changes of L exceed slack/2.\n        If not, which is usually the case after only a few iterations, it will\n        report a previous value for the next several iterations. The stride\n        between updates is set by\n            stride -> stride * (slack/2 / rel_error\n        i.e. it increases more strongly if the rel_error is much below the\n        slack budget.\n        '
    import scipy.sparse
    if (WA is 1):
        self.WA = WA
    else:
        self.WA = scipy.sparse.diags(WA.reshape((- 1)))
    if (WS is 1):
        self.WS = WS
    else:
        self.WS = scipy.sparse.diags(WS.reshape((- 1)))
    self._cb = [utils.ApproximateCache(self._one_over_lipschitzA, slack=slack, max_stride=max_stride), utils.ApproximateCache(self._one_over_lipschitzS, slack=slack, max_stride=max_stride)]
Helper class to compute the Lipschitz constants of grad f.

The __call__ function compute the spectral norms of A or S, which
determine the Lipschitz constant of the respective update steps.

If a weight matrix is used, the stepsize will be upper bounded by
assuming the maximum value of the weights. In the case of varying
weights, it is generally advised to normalize the weight matrix
differently for the A and S updates, therefore two maximum numbers
(WAMax, WSmax) can be set.

Because the spectral norm is expensive to compute, it will only update
the step_size if relative changes of L exceed slack/2.
If not, which is usually the case after only a few iterations, it will
report a previous value for the next several iterations. The stride
between updates is set by
    stride -> stride * (slack/2 / rel_error
i.e. it increases more strongly if the rel_error is much below the
slack budget.
def __init__(self, WA=1, WS=1, slack=0.1, max_stride=100):
    'Helper class to compute the Lipschitz constants of grad f.\n\n        The __call__ function compute the spectral norms of A or S, which\n        determine the Lipschitz constant of the respective update steps.\n\n        If a weight matrix is used, the stepsize will be upper bounded by\n        assuming the maximum value of the weights. In the case of varying\n        weights, it is generally advised to normalize the weight matrix\n        differently for the A and S updates, therefore two maximum numbers\n        (WAMax, WSmax) can be set.\n\n        Because the spectral norm is expensive to compute, it will only update\n        the step_size if relative changes of L exceed slack/2.\n        If not, which is usually the case after only a few iterations, it will\n        report a previous value for the next several iterations. The stride\n        between updates is set by\n            stride -> stride * (slack/2 / rel_error\n        i.e. it increases more strongly if the rel_error is much below the\n        slack budget.\n        '
    import scipy.sparse
    if (WA is 1):
        self.WA = WA
    else:
        self.WA = scipy.sparse.diags(WA.reshape((- 1)))
    if (WS is 1):
        self.WS = WS
    else:
        self.WS = scipy.sparse.diags(WS.reshape((- 1)))
    self._cb = [utils.ApproximateCache(self._one_over_lipschitzA, slack=slack, max_stride=max_stride), utils.ApproximateCache(self._one_over_lipschitzS, slack=slack, max_stride=max_stride)]