Skip to content

Commit

Permalink
fix sobol generator multi stimuli reshape
Browse files Browse the repository at this point in the history
Summary:
Sobol generators would return the incorrect shape when handling multi stimuli generation. This would not cause problem because of the ask converted inadvertantly avoided the problem.

Fixed and clarified the docstring what should happen

Differential Revision: D65239074
  • Loading branch information
JasonKChow authored and facebook-github-bot committed Oct 30, 2024
1 parent 3ab82e6 commit 8c1aac9
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions aepsych/generators/sobol_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,14 @@ def gen(
Args:
num_points (int, optional): Number of points to query.
Returns:
torch.Tensor: Next set of point(s) to evaluate, [num_points x dim].
torch.Tensor: Next set of point(s) to evaluate, [num_points x dim] or [num_points x dim x stimuli_per_trial] if stimuli_per_trial != 1.
"""
grid = self.engine.draw(num_points)
grid = self.lb + (self.ub - self.lb) * grid
if self.stimuli_per_trial == 1:
return grid

return torch.tensor(
np.moveaxis(
grid.reshape(num_points, self.stimuli_per_trial, -1).numpy(),
-1,
-self.stimuli_per_trial,
)
)
return grid.reshape(num_points, -1, self.stimuli_per_trial)

@classmethod
def from_config(cls, config: Config) -> 'SobolGenerator':
Expand Down

0 comments on commit 8c1aac9

Please sign in to comment.