Skip to content
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

Uri/remove negate argument #480

Merged
merged 4 commits into from
Jan 27, 2022
Merged

Uri/remove negate argument #480

merged 4 commits into from
Jan 27, 2022

Conversation

uri-granta
Copy link
Collaborator

@uri-granta uri-granta commented Jan 27, 2022

Remove the negate argument from get_trajectory by having GreedyContinuousThompsonSampling update the callable trajectory to negate it.

Copy link
Collaborator

@hstojic hstojic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@uri-granta uri-granta requested a review from henrymoss January 27, 2022 14:57
Comment on lines +71 to +86
if isinstance(function, TrajectoryFunctionClass):
# we want to negate the trajectory function but otherwise leave it alone,
# as it may have e.g. update and resample methods

class NegatedTrajectory(type(function)): # type: ignore[misc]
def __call__(self, x: TensorType) -> TensorType:
return -1.0 * super().__call__(x)

function.__class__ = NegatedTrajectory
else:

def negated_trajectory(x: TensorType) -> TensorType:
return -1.0 * function(x)

function = negated_trajectory

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clever!

@@ -348,15 +347,12 @@ def test_rff_trajectory_sampler_can_return_negative_trajectory(negate: bool) ->
) # need a gpflow kernel object for random feature decompositions

sampler = RandomFourierFeatureTrajectorySampler(model, num_features=100)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not executed by the new continuous TS so I dont see why would trajectory be negated, by default it should be positive?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

essentially this does not test that a negative trajectory can be returned - this should probably be moved to the cont TS test file and tested there properly

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @henrymoss noted, this test no longer doing anything useful, so I've removed it.

Copy link
Collaborator

@henrymoss henrymoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hstojic hstojic self-requested a review January 27, 2022 15:05
Copy link
Collaborator

@hstojic hstojic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I think I have hit the approve to soon, that test doesn't look good anymore to me (see comments above)

@uri-granta uri-granta merged commit 6a4be22 into develop Jan 27, 2022
@uri-granta uri-granta deleted the uri/remove_negate_argument branch January 27, 2022 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants