-
Notifications
You must be signed in to change notification settings - Fork 20
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
Implement affine pattern recognition for Gaussian substitution #285
Conversation
assert issubclass(type(g_subs), GaussianMixture) | ||
actual = g_subs(**grounding_subs) | ||
expected = g(**ground_subs)(**grounding_subs) | ||
assert_close(actual, expected, atol=1e-3, rtol=1e-4) |
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.
Finally, I can understand the purpose of each statement in this test. :D I will review the logic eager_subs_affine
soon.
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 is great! The Gaussian math looks correct to me. The indexing and alignment code look correct as well but are somewhat intricate.
new_offset = new_offsets[old_k] | ||
new_slice = slice(new_offset, new_offset + old_size) | ||
subs_matrix[..., new_slice, old_slice] = \ | ||
torch.eye(old_size).expand(batch_shape + (-1, -1)) |
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 more advanced slicing isn't covered by existing BlockMatrix
tests in test_gaussian.py
, right? Would it make sense to add a couple of test cases there?
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 do.
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 advanced indexing was already covered, but the particular sparse sequence of entries was not, so I added a test for that.
g_subs = g(**subs) | ||
assert issubclass(type(g_subs), GaussianMixture) | ||
actual = g_subs(**grounding_subs) | ||
expected = g(**ground_subs)(**grounding_subs) |
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 is a very satisfying test 🎉
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.
Look great! Thank Fritz for adding me to review! I understand funsor much better now.
Let's hope this is the last time we'll ever need to write this code 😄 |
Addresses #72
Follows #284
This is step 2/3 in implementing affine recognition for Gaussian funsors. This PR:
Gaussian._eager_subs_affine()
._find_gaps()
to_find_intervals()
for nonuniform block slicing inBlockVector
andBlockMatrix
.Tested
BlockMatrix