Utilities¶
Subpackages¶
Module contents¶
-
class
olympus.utils.HyperParameters(space, **kwargs)[source]¶ Bases:
objectKeeps track of mandatory hyper parameters
Parameters: - space: Dict[str, Space]
A dictionary defining each parameters and their respective space/dim
- kwargs:
A dictionary of defined hyper parameters
Methods
add_parameters([strict])Insert a new parameter value missing_parameters()Returns a dictionary of missing parameters parameters([strict])Returns all the parameters and checks if any are missing
-
class
olympus.utils.LazyCall(fun, *args, **kwargs)[source]¶ Bases:
objectSave the call parameters of a function for it can be invoked at a later date
Methods
__call__(*args, **kwargs)Call self as a function. add_arguments invoke was_invoked
-
class
olympus.utils.TimeThrottler(fun: Callable[[A], R], every=10, callback=None)[source]¶ Bases:
objectLimit how often the function fun is called in seconds
Parameters: - fun:
function to throttle
- every: int
Time in second in between each calls
- callback:
function called when throttled
Examples
throttled_print = TimeThrottler(print, every=1) # Only prints 0 for i in range(0, 10): throttled_print(i) # Prints 0 to 9 for i in range(0, 10): throttled_print(i) time.sleep(1)
Methods
__call__(*args, **kwargs)Call self as a function.
-
olympus.utils.compress_dict(state: Dict[KT, VT]) → Dict[KT, VT][source]¶ Compress a state dictionary and return a json friendly compressed state
-
olympus.utils.decompress_dict(state: Dict[KT, VT]) → Dict[KT, VT][source]¶ Decompress a state dictionary and return its json
-
olympus.utils.find_batch_size(model, shape, low, high, dtype=torch.float32)[source]¶ Find the highest batch size that can fit in memory using binary search