LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
Classes | Functions | Variables
lsst.scarlet.lite.parameters Namespace Reference

Classes

class  AdaproxParameter
 
class  FistaParameter
 
class  FixedParameter
 
class  Parameter
 
class  SingleItemArray
 

Functions

Callable step_function_wrapper (float step)
 
Parameter parameter (np.ndarray|Parameter x)
 
 _adam_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _nadam_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _amsgrad_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _padam_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _adamx_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 _radam_phi_psi (it, g, m, v, vhat, b1, b2, eps, p)
 
 relative_step (np.ndarray x, float factor=0.1, float minimum=0, int|Sequence[int]|None axis=None)
 

Variables

int DEFAULT_ADAPROX_FACTOR = 1e-2
 
dict phi_psi
 

Function Documentation

◆ _adam_phi_psi()

lsst.scarlet.lite.parameters._adam_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 243 of file parameters.py.

243def _adam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
244 # moving averages
245 m[:] = (1 - b1[it]) * g + b1[it] * m
246 v[:] = (1 - b2) * (g**2) + b2 * v
247
248 # bias correction
249 t = it + 1
250 phi = m / (1 - b1[it] ** t)
251 psi = np.sqrt(v / (1 - b2**t)) + eps
252 return phi, psi
253
254
255# noinspection PyUnusedLocal

◆ _adamx_phi_psi()

lsst.scarlet.lite.parameters._adamx_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 298 of file parameters.py.

298def _adamx_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
299 # moving averages
300 m[:] = (1 - b1[it]) * g + b1[it] * m
301 v[:] = (1 - b2) * (g**2) + b2 * v
302
303 phi = m
304 factor = (1 - b1[it]) ** 2 / (1 - b1[it - 1]) ** 2
305 vhat[:] = np.maximum(factor * vhat, v)
306 # sanitize zero-gradient elements
307 if eps > 0:
308 vhat = np.maximum(vhat, eps)
309 psi = np.sqrt(vhat)
310 return phi, psi
311
312
313# noinspection PyUnusedLocal

◆ _amsgrad_phi_psi()

lsst.scarlet.lite.parameters._amsgrad_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 269 of file parameters.py.

269def _amsgrad_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
270 # moving averages
271 m[:] = (1 - b1[it]) * g + b1[it] * m
272 v[:] = (1 - b2) * (g**2) + b2 * v
273
274 phi = m
275 vhat[:] = np.maximum(vhat, v)
276 # sanitize zero-gradient elements
277 if eps > 0:
278 vhat = np.maximum(vhat, eps)
279 psi = np.sqrt(vhat)
280 return phi, psi
281
282

◆ _nadam_phi_psi()

lsst.scarlet.lite.parameters._nadam_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 256 of file parameters.py.

256def _nadam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
257 # moving averages
258 m[:] = (1 - b1[it]) * g + b1[it] * m
259 v[:] = (1 - b2) * (g**2) + b2 * v
260
261 # bias correction
262 t = it + 1
263 phi = (b1[it] * m[:] + (1 - b1[it]) * g) / (1 - b1[it] ** t)
264 psi = np.sqrt(v / (1 - b2**t)) + eps
265 return phi, psi
266
267
268# noinspection PyUnusedLocal

◆ _padam_phi_psi()

lsst.scarlet.lite.parameters._padam_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 283 of file parameters.py.

283def _padam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
284 # moving averages
285 m[:] = (1 - b1[it]) * g + b1[it] * m
286 v[:] = (1 - b2) * (g**2) + b2 * v
287
288 phi = m
289 vhat[:] = np.maximum(vhat, v)
290 # sanitize zero-gradient elements
291 if eps > 0:
292 vhat = np.maximum(vhat, eps)
293 psi = vhat**p
294 return phi, psi
295
296
297# noinspection PyUnusedLocal

◆ _radam_phi_psi()

lsst.scarlet.lite.parameters._radam_phi_psi ( it,
g,
m,
v,
vhat,
b1,
b2,
eps,
p )
protected

Definition at line 314 of file parameters.py.

314def _radam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
315 rho_inf = 2 / (1 - b2) - 1
316
317 # moving averages
318 m[:] = (1 - b1[it]) * g + b1[it] * m
319 v[:] = (1 - b2) * (g**2) + b2 * v
320
321 # bias correction
322 t = it + 1
323 phi = m / (1 - b1[it] ** t)
324 rho = rho_inf - 2 * t * b2**t / (1 - b2**t)
325
326 if rho > 4:
327 psi = np.sqrt(v / (1 - b2**t))
328 r = np.sqrt((rho - 4) * (rho - 2) * rho_inf / (rho_inf - 4) / (rho_inf - 2) / rho)
329 psi /= r
330 else:
331 psi = np.ones(g.shape, g.dtype)
332 # sanitize zero-gradient elements
333 if eps > 0:
334 psi = np.maximum(psi, np.sqrt(eps))
335 return phi, psi
336
337
338# Dictionary to link ADAM variation names to their functional algorithms.

◆ parameter()

Parameter lsst.scarlet.lite.parameters.parameter ( np.ndarray | Parameter x)
Convert a `np.ndarray` into a `Parameter`.

Parameters
----------
x:
    The array or parameter to convert into a `Parameter`.

Returns
-------
result:
    `x`, converted into a `Parameter` if necessary.

Definition at line 165 of file parameters.py.

165def parameter(x: np.ndarray | Parameter) -> Parameter:
166 """Convert a `np.ndarray` into a `Parameter`.
167
168 Parameters
169 ----------
170 x:
171 The array or parameter to convert into a `Parameter`.
172
173 Returns
174 -------
175 result:
176 `x`, converted into a `Parameter` if necessary.
177 """
178 if isinstance(x, Parameter):
179 return x
180 return Parameter(x, {}, 0)
181
182

◆ relative_step()

lsst.scarlet.lite.parameters.relative_step ( np.ndarray x,
float factor = 0.1,
float minimum = 0,
int | Sequence[int] | None axis = None )
Step size set at `factor` times the mean of `X` in direction `axis`

Definition at line 467 of file parameters.py.

472):
473 """Step size set at `factor` times the mean of `X` in direction `axis`"""
474 return np.maximum(minimum, factor * x.mean(axis=axis))

◆ step_function_wrapper()

Callable lsst.scarlet.lite.parameters.step_function_wrapper ( float step)
Wrapper to make a numerical step into a step function

Parameters
----------
step:
    The step to take for a given array.

Returns
-------
step_function:
    The step function that takes an array and returns the
    numerical step.

Definition at line 46 of file parameters.py.

46def step_function_wrapper(step: float) -> Callable:
47 """Wrapper to make a numerical step into a step function
48
49 Parameters
50 ----------
51 step:
52 The step to take for a given array.
53
54 Returns
55 -------
56 step_function:
57 The step function that takes an array and returns the
58 numerical step.
59 """
60 return lambda x: step
61
62

Variable Documentation

◆ DEFAULT_ADAPROX_FACTOR

int lsst.scarlet.lite.parameters.DEFAULT_ADAPROX_FACTOR = 1e-2

Definition at line 43 of file parameters.py.

◆ phi_psi

dict lsst.scarlet.lite.parameters.phi_psi
Initial value:
1= {
2 "adam": _adam_phi_psi,
3 "nadam": _nadam_phi_psi,
4 "amsgrad": _amsgrad_phi_psi,
5 "padam": _padam_phi_psi,
6 "adamx": _adamx_phi_psi,
7 "radam": _radam_phi_psi,
8}

Definition at line 339 of file parameters.py.