soft.utilities package

Submodules

soft.utilities.functions module

Utility functions, such as for getting the powerset of an iterable.

soft.utilities.functions.all_subclasses(cls) Set[Any]

Get all subclasses of the given class, recursively.

Returns:

A set of all subclasses of the given class.

soft.utilities.functions.convert_to_tensor(values: ndarray) Tensor

If the given values are not torch.Tensor, convert them to torch.Tensor.

Parameters:

values – Values such as the centers or widths of a fuzzy set.

Returns:

torch.tensor(np.array(values))

soft.utilities.functions.find_centers_and_widths(data_point, minimums, maximums, alpha: float) List[Dict[str, float]]

Find the centers and widths to be used for a newly created fuzzy set.

Parameters:
  • data_point (1D Numpy array) – A single input_data observation where each column is a feature/attribute.

  • minimums (iterable) – The minimum value per feature in X.

  • maximums (iterable) – The maximum value per feature in X.

  • alpha (float) – A hyperparameter to adjust the generated widths’ coverage.

Returns:

A list of dictionaries, where each dictionary contains the center and width for a newly created fuzzy set (that is to be created later).

soft.utilities.functions.get_most_recent_directory(path_to_folder: str | Path) Path

Get the path to the most recent data within a directory.

Parameters:

path_to_folder – The path to the directory containing the data, models, or logs.

Returns:

The path to the most recent data.

soft.utilities.functions.get_object_attributes(obj_instance) Dict[str, Any]

Get the attributes of an object instance.

soft.utilities.functions.powerset(iterable: Iterable, min_items: int)

Get the powerset of an iterable.

Parameters:
  • iterable – An iterable collection of elements.

  • min_items – The minimum number of items that must be in each subset.

Returns:

The powerset of the given iterable.

soft.utilities.functions.regulator(sigma_1: float, sigma_2: float) float

Regulator function as defined in CLIP.

Parameters:
  • sigma_1 – The left sigma/width.

  • sigma_2 – The right sigma/width.

Returns:

An adjusted sigma so that the produced Gaussian membership function is not warped.

Return type:

sigma (float)

soft.utilities.performance module

Implement functions that may be helpful in improving performance, such as enabling/disabling certain features when the debugger is active.

soft.utilities.performance.is_debugger_active() bool

Determine if the debugger is currently active.

Returns:

Whether the debugger is active (True if it is, False otherwise).

soft.utilities.performance.performance_boost() bool

If the debugger is not active, improve the performance of Torch by disabling some features.

Returns:

True if the performance was boosted, False otherwise.

soft.utilities.reproducibility module

Provides functions that help guarantee reproducibility.

soft.utilities.reproducibility.env_seed(env, seed: int) None

Set the random number generator, and also set the random number generator for gym.env.

Parameters:
  • env – The environment.

  • seed – The seed to use for the random number generator.

Returns:

None

soft.utilities.reproducibility.load_and_override_default_configuration(path: Path) Config

Load the default configuration file and override it with the configuration file given by ‘path’. This function is useful for when you want to override the default configuration settings with a configuration file that is not the default configuration file. For example, you may want to override the default configuration settings with the configuration settings for a specific experiment.

Parameters:
  • path – A file path to the configuration file that should be merged

  • configuration. (with the default)

Returns:

The custom configuration settings.

soft.utilities.reproducibility.load_configuration(file_name: str | Path = 'default_configuration.yaml', convert_data_types: bool = True) Config

Load and return the default configuration that should be used for models, if another overriding configuration is not used in its place.

Parameters:
  • file_name – Union[str, pathlib.Path] Either a file name (str) where the function will look up

  • directory (the *.yml configuration file on the parent) –

  • in (pathlib.Path where the object redirects the function to a specific location that may be)

  • repository. (a subdirectory of this)

  • convert_data_types – Whether to convert or map string values to their true values. For

  • example

  • ratio. (convert "golden" into the golden)

Returns:

The configuration settings.

soft.utilities.reproducibility.parse_configuration(config: Config, reverse=False) Config

Given the configuration, parse through its values and convert them to their true values. For example, convert “golden” into the golden ratio.

Parameters:
  • config – The configuration settings.

  • reverse – Reverse the parsing of the configuration values; used for when saving configuration settings of a KnowledgeBase.

Returns:

The updated configuration settings.

soft.utilities.reproducibility.path_to_project_root() Path

Return the path to the root of the project.

Returns:

The path to the root of the project.

soft.utilities.reproducibility.set_rng(seed: int) None

Set the random number generator.

Parameters:

seed – The seed to use for the random number generator.

Returns:

None

Module contents