-
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
Issue 59 coerce #95
Issue 59 coerce #95
Conversation
|
||
class Embedding(Operator): | ||
"""An operators to cast between spaces.""" | ||
def __init__(self, target, origin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you switch order here? IMO it makes much more sense to mimic Operator
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has plagued me. Basically it "feels good" to write (if op
has Rn
as domain)
op * embed(rn, cudarn)
This is because you can read it nicely from the right. In the end I'll have to agree however, keeping things "as is" is probably better than having a somewhat more convenient special case here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would always read this as "embed rn
into cudarn
", but I'm spoiled by math :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the "feel bad" vs "feel good" is the same as in math, where you have to think twice when your read A o B
and need to map domains and ranges. I can see your point, reading as a "feed" from right to left is somewhat charming, but it interferes too much with the "math common sense".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will get this fixed.
I see the problem. The proper solution to this would be multi-indexing, but that's a large step to take on the CUDA side for such a relatively small fix. The second best solution is what you did. We can for sure adapt the names, maybe |
Probably some options needed, definitely (imo) |
Multi-indexing would also require any further implementations to provide full slicing, I dislike that.(what if a user wanted to use ASTRA storage, would it need slicing?). We'll have to think abit more about this. |
It's not a super pressing issue anyway. Linear arrays are good since anybody supports them, while multiarrays are fancy and in 90 % of the cases require flattening to interact with other libraries. Let's postpone that. |
def __init__(self, origin, target): | ||
assert isinstance(origin, DiscreteLp) | ||
assert isinstance(target, DiscreteLp) | ||
assert origin.grid.shape == target.grid.shape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only be possible if target.exponent <= origin.exponent
for mathematical reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about that, embedding (to me) means, "Do as your told and ignore the consequences". Kindoff like how mathematicians often "identify" things with others. Perhaps the vectors given to this will only be in a subspace where it still works? I think we need a way for users to "force" this through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guy could take a parameter strict=True
which would check the mathematical condition. To me, an embedding is the identity mapping from a space to a superspace, not simply closing your eyes. If users want to go for it, they can set strict=False
. We can also call it force=False
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guy could take a parameter strict=True which would check the mathematical condition.
Sure, but I'd default it to False.
To me, an embedding is the identity mapping from a space to a superspace, not simply closing your eyes.
Then this needs to be renamed. Very few of these are actually to superspaces, and the adjoint would then never be defined (which obviously isn't that useful).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this needs to be renamed. Very few of these are actually to superspaces, and the adjoint would then never be defined (which obviously isn't that useful).
It's a projection then. In that case I'm good with not checking the exponent.
Well, for now it seems like the only way of getting away with it. I don't think it's so bad. There's still the alternative suggestion to make flat default and call the other one |
How about |
Ok, things left to consider here:
|
I think it's actually better this way, that we internally have to use the less intuitive (
Mathematically, the functionality defines a projection. Embedding is not correct, and I don't think we should callit like that then. |
OK, But I think numpy has some of these around, I'll see if they have a naming convention.
You are correct but I don't quite like the sound of that (a bit too long when you start adding cases). I'll think about it some more. |
This has to be taken up at some point, Ill see if I can get to it. Meanwhile regarding |
Should we close this for now? I guess this is so old a new effort would be needed if we want it. I wont delete the branch, for now. |
There doesn't seem to be an urgent need for it right now, so I guess we can have the code lying around in this branch and close the issue for now, as you suggested. |
Initial attempt at issue #59. Not ready for pull.
Some points of discussion/additions
DiscreteLp
<->DiscreteLp
especially if they have different data orders.FnBaseVector.asflatarray
. I highly dislike this, but it shows a problem we have inDiscreteLpVector.asarray
, namelyx.asarray()[index] != x[index]
, imo this doesnt make much sense. I would suggest we move the current behaviour to a method calledDiscreteLpVector.asvoxels()
(or preferably some better name), and leave theasarray
behaviour to match that ofDiscretization
.Edit: Also solved issue #83 since it was "needed" for this.