LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
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 240 of file parameters.py.

240def _adam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
241 # moving averages
242 m[:] = (1 - b1[it]) * g + b1[it] * m
243 v[:] = (1 - b2) * (g**2) + b2 * v
244
245 # bias correction
246 t = it + 1
247 phi = m / (1 - b1[it] ** t)
248 psi = np.sqrt(v / (1 - b2**t)) + eps
249 return phi, psi
250
251
252# 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 295 of file parameters.py.

295def _adamx_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
296 # moving averages
297 m[:] = (1 - b1[it]) * g + b1[it] * m
298 v[:] = (1 - b2) * (g**2) + b2 * v
299
300 phi = m
301 factor = (1 - b1[it]) ** 2 / (1 - b1[it - 1]) ** 2
302 vhat[:] = np.maximum(factor * vhat, v)
303 # sanitize zero-gradient elements
304 if eps > 0:
305 vhat = np.maximum(vhat, eps)
306 psi = np.sqrt(vhat)
307 return phi, psi
308
309
310# 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 266 of file parameters.py.

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

◆ _nadam_phi_psi()

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

Definition at line 253 of file parameters.py.

253def _nadam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
254 # moving averages
255 m[:] = (1 - b1[it]) * g + b1[it] * m
256 v[:] = (1 - b2) * (g**2) + b2 * v
257
258 # bias correction
259 t = it + 1
260 phi = (b1[it] * m[:] + (1 - b1[it]) * g) / (1 - b1[it] ** t)
261 psi = np.sqrt(v / (1 - b2**t)) + eps
262 return phi, psi
263
264
265# 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 280 of file parameters.py.

280def _padam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
281 # moving averages
282 m[:] = (1 - b1[it]) * g + b1[it] * m
283 v[:] = (1 - b2) * (g**2) + b2 * v
284
285 phi = m
286 vhat[:] = np.maximum(vhat, v)
287 # sanitize zero-gradient elements
288 if eps > 0:
289 vhat = np.maximum(vhat, eps)
290 psi = vhat**p
291 return phi, psi
292
293
294# 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 311 of file parameters.py.

311def _radam_phi_psi(it, g, m, v, vhat, b1, b2, eps, p):
312 rho_inf = 2 / (1 - b2) - 1
313
314 # moving averages
315 m[:] = (1 - b1[it]) * g + b1[it] * m
316 v[:] = (1 - b2) * (g**2) + b2 * v
317
318 # bias correction
319 t = it + 1
320 phi = m / (1 - b1[it] ** t)
321 rho = rho_inf - 2 * t * b2**t / (1 - b2**t)
322
323 if rho > 4:
324 psi = np.sqrt(v / (1 - b2**t))
325 r = np.sqrt((rho - 4) * (rho - 2) * rho_inf / (rho_inf - 4) / (rho_inf - 2) / rho)
326 psi /= r
327 else:
328 psi = np.ones(g.shape, g.dtype)
329 # sanitize zero-gradient elements
330 if eps > 0:
331 psi = np.maximum(psi, np.sqrt(eps))
332 return phi, psi
333
334
335# 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 464 of file parameters.py.

469):
470 """Step size set at `factor` times the mean of `X` in direction `axis`"""
471 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 336 of file parameters.py.