-
Notifications
You must be signed in to change notification settings - Fork 130
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
Dim tags matching should use allow_same_spatial_dim=False
#865
Comments
The output feature dim is usually never the same as the input feature dim. And also, it is not derived from the input feature dim in any way. They are completely independent. So |
Ah yeah, you're right, the So really, I think specifying Logically, this does not make sense 100%, because the in and out dims should logically be different, but we matched them before always anyway, and in the future, we discourage anyone from using |
Also the current matching logic is just dangerously broken and depends on the order of axes, e.g. this fails currently: def test_same_spatial_dim():
foo_dim = SpatialDim("foo", 3)
bar_dim = SpatialDim("bar", 3)
x = Data("a", dim_tags=[foo_dim, bar_dim])
y = Data("b", dim_tags=[bar_dim, foo_dim])
# test with default is_equal_opts=None
assert_equal(x.find_matching_dim_map(y, other_axes=[0, 1]), {0: 1, 1: 0}) # returns {0: 0, 1: 1} currently We should probably just at least throw an error here. |
Note that I stumbled upon this (or related) specifically for the But actually, I did not fully think through it, whether this is maybe difficult for users who did not adapt to use dim tags. Maybe not for |
I'm now thinking whether my proposed solution from from #666 is maybe really the better way which would have avoided these issues:
Again we should think about the quality (#634). When comparing a user-generated dim tag to another user-generated dim tag, it should be strict. When comparing an auto-created dim tag to another auto-created dim tag, it can use the But yes, we also should think about having it all really well defined and the code should be clean. See #975. |
We have the |
This is kind of an follow up to #666.
I have the problem currently, that
SpatialDim("a", 1)
matchesSpatialDim("b", 1)
in many cases, e.g.get_common_data
,copy_compatible_to
andfind_matching_dim_map
used byGatherLayer
/DotLayer
/etc.Looking at the
Dim.is_equal
code,allow_same_spatial_dim
matches exactly iftreat_feature_as_spatial
which e.g.get_common_data
sets)self
andother
are equal, but notNone
For my case, I definitely do not want these axes to match (they are not related in any way).
But this kind of matching is currently necessary for something like this:
This is also because currently,
LinearLayer
does not setderived_from_tag
on its output feature dim.Then,
derived_matches
would catch this.We can fix
LinearLayer
and to do this properly (currently this is via_base_get_out_data_from_opts
, when creating a feature dim tag, I think it should just derive it from its input feature dim tag).For user specified
out_dim
s however, we would not automatically set derived from to the input dim tag.For other cases, this is more difficult maybe.
E.g. if you have two inputs with different time axes, and then split into the same dim size.
Then, the user would maybe want these axes to match, but they are in no way derived from the same thing.
Another solution is, similar to what @albertz wrote in #666, to separate user defined dim tags and automatically created ones. Then, user defined ones could have a more restrictive matching logic.
The text was updated successfully, but these errors were encountered: