losses
¶
Data losses definitions.
Classes:
-
LossRegularizer
–Base class for the regularizer losses.
-
LossSWTN
–Multi-level n-dimensional stationary wavelet transform loss function.
-
LossTGV
–Total Generalized Variation loss function.
-
LossTV
–Total Variation loss function.
Functions:
-
get_nd_wl_filters
–Generate all possible N-D separable wavelet filters.
-
swt_nd
–Perform N-dimensional Stationary Wavelet Transform (SWT).
LossRegularizer
¶
Bases: MSELoss
Base class for the regularizer losses.
LossSWTN
¶
LossSWTN(
wl_dec_lo: Tensor,
wl_dec_hi: Tensor,
lambda_val: float,
size_average=None,
reduce=None,
reduction: str = "mean",
isotropic: bool = True,
levels: int = 2,
n_dims: int = 2,
min_approx: bool = False,
)
Bases: LossRegularizer
Multi-level n-dimensional stationary wavelet transform loss function.
Methods:
-
forward
–Compute wavelet decomposition on current batch.
Source code in src/autoden/losses.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
forward
¶
forward(img: Tensor) -> Tensor
Compute wavelet decomposition on current batch.
Source code in src/autoden/losses.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
LossTGV
¶
LossTGV(
lambda_val: float,
size_average=None,
reduce=None,
reduction: str = "mean",
isotropic: bool = True,
n_dims: int = 2,
)
Bases: LossTV
Total Generalized Variation loss function.
Methods:
-
forward
–Compute total variation statistics on current batch.
Source code in src/autoden/losses.py
39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
forward
¶
forward(img: Tensor) -> Tensor
Compute total variation statistics on current batch.
Source code in src/autoden/losses.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
LossTV
¶
LossTV(
lambda_val: float,
size_average=None,
reduce=None,
reduction: str = "mean",
isotropic: bool = True,
n_dims: int = 2,
)
Bases: LossRegularizer
Total Variation loss function.
Methods:
-
forward
–Compute total variation statistics on current batch.
Source code in src/autoden/losses.py
39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
forward
¶
forward(img: Tensor) -> Tensor
Compute total variation statistics on current batch.
Source code in src/autoden/losses.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
get_nd_wl_filters
¶
Generate all possible N-D separable wavelet filters.
Source code in src/autoden/losses.py
108 109 110 111 112 113 114 115 116 117 118 119 |
|
swt_nd
¶
swt_nd(
x: Tensor,
wl_dec_lo: Tensor,
wl_dec_hi: Tensor,
level: int = 1,
normalize: str | None = None,
) -> list[list[Tensor]]
Perform N-dimensional Stationary Wavelet Transform (SWT).
Parameters:
-
x
(Tensor
) –Input tensor of shape (B, 1, *dims) where dims can be 1D, 2D, or 3D.
-
wl_dec_lo
(Tensor
) –Low-pass wavelet decomposition filter.
-
wl_dec_hi
(Tensor
) –High-pass wavelet decomposition filter.
-
level
(int
, default:1
) –Number of decomposition levels (default is 1).
-
normalize
(str or None
, default:None
) –Normalization method ('none', 'energy', or 'scale'). If None, no normalization is applied (default is None).
Returns:
-
list of list of pt.Tensor
–List like [[approx], [detail_vols], ..., [detail_vols]].
Notes
The function performs the SWT on the input tensor x
using the specified wavelet filters and decomposition level.
The output is a list of lists, where each inner list contains the decomposition volumes. The first inner list contains
the approximation coefficients, and the subsequent inner lists contain the detail coefficients for each level.
Source code in src/autoden/losses.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|