Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0d33ba9806+b932483eba,g0fba68d861+d53f2a615d,g1e78f5e6d3+1e869f36eb,g1ec0fe41b4+f536777771,g1fd858c14a+d5f4961c99,g35bb328faa+fcb1d3bbc8,g4af146b050+2e821d8f6b,g4d2262a081+b02c98aa00,g53246c7159+fcb1d3bbc8,g5a012ec0e7+b20b785ecb,g60b5630c4e+b932483eba,g67b6fd64d1+4086c0989b,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g87b7deb4dc+7d8c31d03d,g8852436030+a639f189fc,g89139ef638+4086c0989b,g9125e01d80+fcb1d3bbc8,g94187f82dc+b932483eba,g989de1cb63+4086c0989b,g9f33ca652e+898eabdf38,g9f7030ddb1+b068313d7a,ga2b97cdc51+b932483eba,ga44b1db4f6+2bd830756e,gabe3b4be73+1e0a283bba,gabf8522325+fa80ff7197,gb1101e3267+f4f1608365,gb58c049af0+f03b321e39,gb89ab40317+4086c0989b,gcf25f946ba+a639f189fc,gd6cbbdb0b4+af3c3595f5,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+4078fef7e5,ge278dab8ac+d65b3c2b70,ge410e46f29+4086c0989b,gf67bdafdda+4086c0989b,gfe06eef73a+6e83fc67a4,v29.0.0.rc5
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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.