LSST Applications g04e9c324dd+8c5ae1fdc5,g134cb467dc+b203dec576,g18429d2f64+358861cd2c,g199a45376c+0ba108daf9,g1fd858c14a+dd066899e3,g262e1987ae+ebfced1d55,g29ae962dfc+72fd90588e,g2cef7863aa+aef1011c0b,g35bb328faa+8c5ae1fdc5,g3fd5ace14f+b668f15bc5,g4595892280+3897dae354,g47891489e3+abcf9c3559,g4d44eb3520+fb4ddce128,g53246c7159+8c5ae1fdc5,g67b6fd64d1+abcf9c3559,g67fd3c3899+1f72b5a9f7,g74acd417e5+cb6b47f07b,g786e29fd12+668abc6043,g87389fa792+8856018cbb,g89139ef638+abcf9c3559,g8d7436a09f+bcf525d20c,g8ea07a8fe4+9f5ccc88ac,g90f42f885a+6054cc57f1,g97be763408+06f794da49,g9dd6db0277+1f72b5a9f7,ga681d05dcb+7e36ad54cd,gabf8522325+735880ea63,gac2eed3f23+abcf9c3559,gb89ab40317+abcf9c3559,gbf99507273+8c5ae1fdc5,gd8ff7fe66e+1f72b5a9f7,gdab6d2f7ff+cb6b47f07b,gdc713202bf+1f72b5a9f7,gdfd2d52018+8225f2b331,ge365c994fd+375fc21c71,ge410e46f29+abcf9c3559,geaed405ab2+562b3308c0,gf9a733ac38+8c5ae1fdc5,w.2025.35
LSST Data Management Base Package
Loading...
Searching...
No Matches
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.