Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions emukit/core/optimization/gradient_acquisition_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def _optimize(self, acquisition: Acquisition, context_manager: ContextManager) -
x = np.array(context_manager.context_values)[None, :]
return x, f(x)

# Prepare gradient function (if available)
if acquisition.has_gradients:

def f_df(x):
def df(x):
f_value, df_value = acquisition.evaluate_with_gradients(x)
return -f_value, -df_value

# Return negated gradient (since we negated f)
return -df_value
else:
f_df = None
df = None

optimizer = self._get_optimizer(context_manager)
anchor_points_generator = ObjectiveAnchorPointsGenerator(self.space, acquisition, num_samples=self.num_samples)
Expand All @@ -70,7 +70,7 @@ def f_df(x):
optimized_points = []
for a in anchor_points:
optimized_point = apply_optimizer(
optimizer, a, space=self.space, f=f, df=None, f_df=f_df, context_manager=context_manager
optimizer, a, space=self.space, f=f, df=df, context_manager=context_manager
)
optimized_points.append(optimized_point)

Expand Down
Loading
Loading