-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Representing vector- and tensor-valued functions #908
Comments
My suggestion is to use
pros: No need for another parameter, no redundancy
First is i.m.o. the only option, sadly. This needs to match productspace
Certainly, but I'm not sure what. Perhaps call the "full" shape and "full" ndim as now, to match numpy. Then perhaps
No ideal solution here, but overall I'd say not to add too much to productspace, e.g. do not port everything but add as needed. Also try to make sure most things are transparent. We may want to reopen and solve #157 (Multidimensional product spaces) in order to make the syntax more similar for the basic cases.
I have trust in you! |
That's actually a very nice idea, makes total sense. It will also be a perfect match for continuous function spaces with
I had also thought of
In some sense, the |
This is now largely done in #861, at least on the level of >>> intv = odl.IntervalProd(0, 1)
>>> scal_spc = odl.FunctionSpace(intv)
>>> elem = scal_spc.element(lambda x: x + 1)
>>> elem(0)
1.0
>>> elem([0, 1])
array([ 1., 2.])
>>>
>>> vec_spc = odl.FunctionSpace(intv, out_dtype=(float, (2,))) # 2 components
>>> # Possibility 1: sequence of functions
>>> elem1 = vec_spc.element([lambda x: x + 1, lambda x: x - 1])
>>> elem1(0)
array([ 1., -1.])
>>> elem1([0, 1])
array([[ 1., 2.],
[-1., 0.]])
>>>
>>> # Possibility 2: function returning a sequence
>>> elem2 = vec_spc.element(lambda x: (x + 1, x - 1))
>>> elem2(0)
array([ 1., -1.])
>>> elem1([0, 1])
array([[ 1., 2.],
[-1., 0.]]) Of course, things also work with higher order tensors, and you can use constants in sequences: >>> tens_spc = odl.FunctionSpace(intv, out_dtype=(float, (2, 3)))
>>> elem = tens_spc.element([[lambda x: x, np.abs, np.negative],
[lambda x: x + 1, 0, 0]])
>>> elem1(0)
array([[ 0., 0., 0.],
[ 1., 0., 0.]])
>>> elem([0, 1])
array([[[ 0., 1.],
[ 0., 1.],
[ 0., -1.]],
[[ 1., 2.],
[ 0., 0.],
[ 0., 0.]]]) Support for |
Looking great to me! |
This is very related to #342. |
I'll keep this issue open after the tensor branch is in, for the work on the discretized version of vector- and tensor-valued functions. That will remain as TODO. |
I agree, but that should be done ASAP once the branch is in. |
I guess this is on the table now |
I'm working on it, have a WIP branch. |
Might as well make a PR to make it visible then! |
Changes in detail: - Add dtype with shape to DiscreteLp (mostly __repr__, factory functions and some downstream methods). As a consequence, `shape_[in,out]` and `ndim_[in,out]` are added for the different types of axes, as well as `scalar_dtype`. - Add `PerAxisWeighting` and make it the default for `DiscreteLp` type spaces. Reason: this way the `tspace` knows how to deal with removed axes etc. This is important for a smooth experience with indexing and reductions over axes. Helpers for slicing weightings help structure this task. - Implement `__getitem__` for `TensorSpace` and `DiscreteLp`, including (hopefully) reasonable propagation of weights. The new `simulate_slicing` utility function simplifies this task. - Allow indexing with ODL tensors of boolean or integer dtype. - Implement correct weighting for backprojections with non-uniform angles, using per-axis weighting and a new helper `adjoint_weightings` to apply the weightings in an efficient way. The correct weighting from the range of `RayTransform` is determined by the new `proj_space_weighting` helper. - Change the space `_*_impl` methods to always expect and return Numpy arrays, and adapt the calling code. - Change behavior of `norm` and `dist` to ignoring weights for `exponent=inf`, in accordance with math. - Improve speed of `all_equal` for comparison of arrays. - Account for `None` entries in indices in the `normalized_index_expression` helper, thus allowing creation of new axes. - Remove `dicsr_sequence_space`, it was largely unused and just a maintenance burden. Use a regular `uniform-discr` from zero to `shape` instead. - Remove `Weighting.equiv()` mehtods, never used and hard to maintain (n^2 possibilities). - Remove the (largely useless) `_weighting` helper to create weighting instances since it would have been ambiguous with sequences of scalars (array or per axis?). Also remove the `npy_weighted_*` functions, they were useless, too. - Remove some dead code from tomo/util. - A bunch of minor fixes, as usual. Closes: odlgroup#908, odlgroup#907, odlgroup#1113, odlgroup#965, odlgroup#286, odlgroup#267, odlgroup#1001
Changes in detail: - Add dtype with shape to DiscreteLp (mostly __repr__, factory functions and some downstream methods). As a consequence, `shape_[in,out]` and `ndim_[in,out]` are added for the different types of axes, as well as `scalar_dtype`. - Add `PerAxisWeighting` and make it the default for `DiscreteLp` type spaces. Reason: this way the `tspace` knows how to deal with removed axes etc. This is important for a smooth experience with indexing and reductions over axes. Helpers for slicing weightings help structure this task. - Implement `__getitem__` for `TensorSpace` and `DiscreteLp`, including (hopefully) reasonable propagation of weights. The new `simulate_slicing` utility function simplifies this task. - Allow indexing with ODL tensors of boolean or integer dtype. - Implement correct weighting for backprojections with non-uniform angles, using per-axis weighting and a new helper `adjoint_weightings` to apply the weightings in an efficient way. The correct weighting from the range of `RayTransform` is determined by the new `proj_space_weighting` helper. - Change the space `_*_impl` methods to always expect and return Numpy arrays, and adapt the calling code. - Change behavior of `norm` and `dist` to ignoring weights for `exponent=inf`, in accordance with math. - Improve speed of `all_equal` for comparison of arrays. - Account for `None` entries in indices in the `normalized_index_expression` helper, thus allowing creation of new axes. - Remove `dicsr_sequence_space`, it was largely unused and just a maintenance burden. Use a regular `uniform-discr` from zero to `shape` instead. - Remove `Weighting.equiv()` mehtods, never used and hard to maintain (n^2 possibilities). - Remove the (largely useless) `_weighting` helper to create weighting instances since it would have been ambiguous with sequences of scalars (array or per axis?). Also remove the `npy_weighted_*` functions, they were useless, too. - Remove some dead code from tomo/util. - A bunch of minor fixes, as usual. Closes: odlgroup#908 Closes: odlgroup#907 Closes: odlgroup#1113 Closes: odlgroup#965 Closes: odlgroup#286 Closes: odlgroup#267 Closes: odlgroup#1001
Changes in detail: - Add dtype with shape to DiscreteLp (mostly __repr__, factory functions and some downstream methods). As a consequence, `shape_[in,out]` and `ndim_[in,out]` are added for the different types of axes, as well as `scalar_dtype`. - Add `PerAxisWeighting` and make it the default for `DiscreteLp` type spaces. Reason: this way the `tspace` knows how to deal with removed axes etc. This is important for a smooth experience with indexing and reductions over axes. Helpers for slicing weightings help structure this task. - Implement `__getitem__` for `TensorSpace` and `DiscreteLp`, including (hopefully) reasonable propagation of weights. The new `simulate_slicing` utility function simplifies this task. - Allow indexing with ODL tensors of boolean or integer dtype. - Implement correct weighting for backprojections with non-uniform angles, using per-axis weighting and a new helper `adjoint_weightings` to apply the weightings in an efficient way. The correct weighting from the range of `RayTransform` is determined by the new `proj_space_weighting` helper. - Change the space `_*_impl` methods to always expect and return Numpy arrays, and adapt the calling code. - Change behavior of `norm` and `dist` to ignoring weights for `exponent=inf`, in accordance with math. - Improve speed of `all_equal` for comparison of arrays. - Account for `None` entries in indices in the `normalized_index_expression` helper, thus allowing creation of new axes. - Remove `dicsr_sequence_space`, it was largely unused and just a maintenance burden. Use a regular `uniform-discr` from zero to `shape` instead. - Remove `Weighting.equiv()` mehtods, never used and hard to maintain (n^2 possibilities). - Remove the (largely useless) `_weighting` helper to create weighting instances since it would have been ambiguous with sequences of scalars (array or per axis?). Also remove the `npy_weighted_*` functions, they were useless, too. - Remove some dead code from tomo/util. - A bunch of minor fixes, as usual. Closes: odlgroup#908 Closes: odlgroup#907 Closes: odlgroup#1113 Closes: odlgroup#965 Closes: odlgroup#286 Closes: odlgroup#267 Closes: odlgroup#1001
Changes in detail: - Add dtype with shape to DiscreteLp (mostly __repr__, factory functions and some downstream methods). As a consequence, `shape_[in,out]` and `ndim_[in,out]` are added for the different types of axes, as well as `scalar_dtype`. - Add `PerAxisWeighting` and make it the default for `DiscreteLp` type spaces. Reason: this way the `tspace` knows how to deal with removed axes etc. This is important for a smooth experience with indexing and reductions over axes. Helpers for slicing weightings help structure this task. - Implement `__getitem__` for `TensorSpace` and `DiscreteLp`, including (hopefully) reasonable propagation of weights. The new `simulate_slicing` utility function simplifies this task. - Allow indexing with ODL tensors of boolean or integer dtype. - Implement correct weighting for backprojections with non-uniform angles, using per-axis weighting and a new helper `adjoint_weightings` to apply the weightings in an efficient way. The correct weighting from the range of `RayTransform` is determined by the new `proj_space_weighting` helper. - Change the space `_*_impl` methods to always expect and return Numpy arrays, and adapt the calling code. - Change behavior of `norm` and `dist` to ignoring weights for `exponent=inf`, in accordance with math. - Improve speed of `all_equal` for comparison of arrays. - Account for `None` entries in indices in the `normalized_index_expression` helper, thus allowing creation of new axes. - Remove `dicsr_sequence_space`, it was largely unused and just a maintenance burden. Use a regular `uniform-discr` from zero to `shape` instead. - Remove `Weighting.equiv()` mehtods, never used and hard to maintain (n^2 possibilities). - Remove the (largely useless) `_weighting` helper to create weighting instances since it would have been ambiguous with sequences of scalars (array or per axis?). Also remove the `npy_weighted_*` functions, they were useless, too. - Remove some dead code from tomo/util. - A bunch of minor fixes, as usual. Closes: odlgroup#908 Closes: odlgroup#907 Closes: odlgroup#1113 Closes: odlgroup#965 Closes: odlgroup#286 Closes: odlgroup#267 Closes: odlgroup#1001
When #861 is in, we'll have to deal with the issue of how to represent vector- and tensor-valued functions properly. Questions are:
DiscreteLp
: Where to put the additional axes for the function range?shape
andndim
? If yes, how to name them?ProductSpace
based implementations of the same thing?Answer to 1: Clearly first, to keep compatibility with
ProductSpace
based versions of vector-valued functions.Otherwise: ?
The text was updated successfully, but these errors were encountered: