You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful if the current index of a Sampler instance could be accessed multiple times within an iteration without changing. For example, when both an SGFunction and a Preconditioner depend on the choice of subset and need to reference the same index.
Right now, I think that this can be done with:
current_index=algorithm.f.data_passes_indices[-1]
as long as the random samplers have a fixed seed. However, this feels like an unnecessary workaround rather than accessing the sampler itself
Possible Solutions
Adding a current_index property to Sampler
This would store the last sampled index and allow multiple accesses within the same iteration.
Modifying Sampler.next() to accept algorithm.iteration
This would ensure the index remains consistent when accessed multiple times within the same iteration but, I guess, would require some changes to the way stochastic functions work.
Either approach would make it easier to ensure consistency when using stochastic samplers.
Cheers
Sam
Environment
24.2.1.dev11+gab65d759.d20241129 gab65d759 3.10.12 (main, Jan 17 2025, 14:35:34) [GCC 11.4.0] linux
edit: a simpler way to get the current index, typo
The text was updated successfully, but these errors were encountered:
Discussed in the stochastic catch-up meeting today. Decided on:
Adding a current_index property to Sampler. This would store the last sampled index and allow multiple accesses within the same iteration.
The sampler saving the number of times it has been called and then using a property "get_previous_samples" or similar, recalculate all previous samples
Description
It would be useful if the current index of a
Sampler
instance could be accessed multiple times within an iteration without changing. For example, when both anSGFunction
and aPreconditioner
depend on the choice of subset and need to reference the same index.Right now, I think that this can be done with:
as long as the random samplers have a fixed seed. However, this feels like an unnecessary workaround rather than accessing the sampler itself
Possible Solutions
Adding a
current_index
property toSampler
This would store the last sampled index and allow multiple accesses within the same iteration.
Modifying
Sampler.next()
to acceptalgorithm.iteration
This would ensure the index remains consistent when accessed multiple times within the same iteration but, I guess, would require some changes to the way stochastic functions work.
Either approach would make it easier to ensure consistency when using stochastic samplers.
Cheers
Sam
Environment
24.2.1.dev11+gab65d759.d20241129 gab65d759 3.10.12 (main, Jan 17 2025, 14:35:34) [GCC 11.4.0] linux
edit: a simpler way to get the current index, typo
The text was updated successfully, but these errors were encountered: