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,
ndims: 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
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
forward
¶
forward(img: Tensor) -> Tensor
Compute wavelet decomposition on current batch.
Source code in src/autoden/losses.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
LossTGV
¶
LossTGV(
lambda_val: float,
size_average=None,
reduce=None,
reduction: str = "mean",
isotropic: bool = True,
ndims: 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,
ndims: 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
143 144 145 146 147 148 149 150 151 152 153 154 |
|
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
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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|