Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Allow constant inputs to cost functions to be passed as floats #150
Allow constant inputs to cost functions to be passed as floats #150
Changes from 8 commits
8c65a5c
63bd33b
bee7bc5
67cbaa5
d9b3e6f
c4cc96b
e3e3be3
9c6d6af
7ddfff2
fcb87d1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Here we can check that
cost_function.eff_radius is eff_radius
.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.
You can delete the line above that has the
isinstance
check now.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.
Here we can add another check that
cost_function.eff_radius.data is eff_radius_t
.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.
@luisenp While
assert cost_function.eff_radius.data is eff_radius_t
gives error as one istensor
and other isth.Variable
.Is it better to useassert torch.allclose(cost_function.eff_radius.data,eff_radius_t)
?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'm a bit confused. Shouldn't both
cost_function.eff_radius.data
(notice,.data
) andeff_radius_t
be both torch tensors?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.
@luisenp when i try to do
assert cost_function.eff_radius.data is eff_radius_t
i get this error which expained aboveThere 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.
Ah, right, it's because of the
view(-1, 1)
we added. In this case, let's stick to compare that they are close in value as you had initially.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.
@luisenp Then can you take a look at PR. I've already committed the changes
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.
Here we can first set up some random value for
eff_radius_f
and then add an additional check thatnp.isclose(cost_function.eff_radius.data.item(), eff_radius_f)
.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.
@luisenp
we're already giving a random value to
eff_radius_f=1.0
So is this enough
assert np.isclose(cost_function.eff_radius.data.item(), eff_radius_f)
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.
By random I mean sampling a new value every iteration rather than hardcoding to 1.0.
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.
After the
ndim
check below, we can adddt.data = self.dt.data.view(-1, 1)
, to make sure we have a batch dimension as well, as discussed above.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 have added a fix for this class in #157, make sure you merge those changes as well.
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.
Similar comment about maintaining a batch shape 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.
Add similar modifications to the test here, as mentioned above.
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.
We don't need the second check for
q_inv_v
.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.
Sorry, didn't think of this before, but we should also check that
cost_weight.dt
has a batch dimension. And similar foreff_radius_t
in the other cost function. We are also missing the checknp.isclose(cost_function.eff_radius.data.item(), eff_radius_f)
(and similar fordt
).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.
@jeffin07 Missing the
np.allclose()
check foreff_radius_f
and also checking that the batch dimension is present.