Utilities#
Utility functions for GPU management, training helpers, and network configuration.
GPU Management#
- rate.utils.set_gpu(gpu: str, frac: float) device [source]#
Function to specify which GPU to use.
- Parameters:
gpu (str) – String label for gpu (i.e. ‘0’).
frac (float) – GPU memory fraction (i.e. 0.3 for 30% of the total memory).
- Returns:
PyTorch device object for the specified GPU or CPU.
- Return type:
torch.device
Utility Functions#
- rate.utils.restricted_float(x: str | float) float [source]#
Helper function for restricting input arg to range from 0 to 1.
- Parameters:
x (Union[str, float]) – String or float representing a number.
- Returns:
The validated float value.
- Return type:
float
- Raises:
argparse.ArgumentTypeError – If the value is not in range [0.0, 1.0].
- rate.utils.str2bool(v: str | bool) bool [source]#
Helper function to parse boolean input args.
- Parameters:
v (Union[str, bool]) – String or boolean representing true or false.
- Returns:
The parsed boolean value.
- Return type:
bool
- Raises:
argparse.ArgumentTypeError – If the value cannot be parsed as a boolean.