-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Markus Semmler
committed
Sep 1, 2023
1 parent
c28ce5e
commit 6dee93d
Showing
8 changed files
with
58 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import annotations | ||
|
||
from copy import deepcopy | ||
from typing import Callable, Tuple | ||
|
||
from pydvl.utils.types import Seed | ||
|
||
|
||
def call_fn_multiple_seeds( | ||
fn: Callable, *args, seeds: Tuple[Seed, ...], **kwargs | ||
) -> Tuple: | ||
""" | ||
Execute a function multiple times with different seeds. It copies the arguments | ||
and keyword arguments before passing them to the function. | ||
Args: | ||
fn: The function to execute. | ||
args: The arguments to pass to the function. | ||
seeds: The seeds to use. | ||
kwargs: The keyword arguments to pass to the function. | ||
Returns: | ||
A tuple of the results of the function. | ||
""" | ||
return tuple(fn(*deepcopy(args), **deepcopy(kwargs), seed=seed) for seed in seeds) |