-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
475a7cc
commit 7603375
Showing
11 changed files
with
84 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""MSE-Functional.""" | ||
|
||
from collections.abc import Sequence | ||
|
||
import torch | ||
|
||
from mrpro.operators.functionals.L2NormSquared import L2NormSquared | ||
|
||
|
||
class MSE(L2NormSquared): | ||
r"""Functional class for the mean square error. | ||
This makes use of the functional L2NormSquared. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
weight: torch.Tensor | complex = 1.0, | ||
target: torch.Tensor | None | complex = None, | ||
dim: int | Sequence[int] | None = None, | ||
divide_by_n: bool = True, | ||
keepdim: bool = False, | ||
) -> None: | ||
r"""Initialize a Functional. | ||
We assume that functionals are given in the form | ||
:math:`f(x) = \phi ( weight ( x - target))` | ||
for some functional :math:`\phi`. | ||
Parameters | ||
---------- | ||
functional | ||
functional to be employed | ||
weight | ||
weight parameter (see above) | ||
target | ||
target element - often data tensor (see above) | ||
dim | ||
dimension(s) over which functional is reduced. | ||
All other dimensions of `weight ( x - target)` will be treated as batch dimensions. | ||
divide_by_n | ||
if true, the result is scaled by the number of elements of the dimensions index by `dim` in | ||
the tensor `weight ( x - target)`. If true, the functional is thus calculated as the mean, | ||
else the sum. | ||
keepdim | ||
if true, the dimension(s) of the input indexed by dim are maintained and collapsed to singeltons, | ||
else they are removed from the result. | ||
""" | ||
super().__init__(weight=weight, target=target, dim=dim, divide_by_n=divide_by_n, keepdim=keepdim) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from mrpro.operators.functionals.L1Norm import L1Norm | ||
from mrpro.operators.functionals.L1NormViewAsReal import L1NormViewAsReal | ||
from mrpro.operators.functionals.L2NormSquared import L2NormSquared | ||
from mrpro.operators.functionals.MSE import MSE | ||
from mrpro.operators.functionals.ZeroFunctional import ZeroFunctional | ||
__all__ = ["L1Norm", "L1NormViewAsReal", "L2NormSquared", "MSEDataDiscrepancy", "ZeroFunctional"] | ||
__all__ = ["L1Norm", "L1NormViewAsReal", "L2NormSquared", "MSE", "ZeroFunctional"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from mrpro.operators.functionals.L1NormViewAsReal import L1NormViewAsReal | ||
from mrpro.operators.functionals.L1Norm import L1Norm | ||
from mrpro.operators.functionals.L2NormSquared import L2NormSquared | ||
from mrpro.operators.functionals.MSE import MSE | ||
from mrpro.operators.functionals.ZeroFunctional import ZeroFunctional |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters