Shortcuts

torcheeg.utils

Shared utilities live in the single torcheeg/utils.py module. Utilities that belong to a specific domain remain in that domain’s existing utils.py. For plotting APIs, see torcheeg.visualizers.

Files and experiments

torcheeg.utils.seed_everything(seed)[source][source]
torcheeg.utils.download_url(url: str, folder: str, verbose: bool = True, filename: None | str = None)[source][source]
torcheeg.utils.get_package_dir_path()[source][source]
torcheeg.utils.get_random_dir_path(root_path='.torcheeg', dir_prefix='tmp')[source][source]

Generates a unique folder name based on the current timestamp and a random suffix. The folder name is intended to be used for creating a temporary cache folder in torcheeg.

Returns:

A unique folder name.

Return type:

str

torcheeg.utils.get_temp_dir_path()[source][source]

Shared cache operations

Dataset and split-specific fingerprinting stays in datasets.utils and model_selection.utils. These functions provide their shared cache machinery.

torcheeg.utils.compute_fingerprint(value)[source][source]

Return the SHA256 digest of bytes describing cache inputs.

torcheeg.utils.compute_checksum(path)[source][source]

Return the SHA256 digest of a file using bounded memory.

torcheeg.utils.validate_cache(path, fingerprint, files=None)[source][source]

Raise ValueError if cache identity or output checksums do not match.

torcheeg.utils.ensure_cache(path, fingerprint, writer, files=None, validator=None)[source][source]

Reuse a validated cache or build and publish it under a file lock.

Optional dependencies

class torcheeg.utils.LazyLoader(lib_name, install_hint=None)[source][source]

LazyLoader loads its module on first attribute access. Resolving a class as a base also accesses an attribute, so a top-level class definition triggers the import at that point. Importing shared utilities does not load visualizers. Pass an optional install_hint to provide dependency-specific installation instructions; the loader itself does not assume a particular package.

Migration

Replace direct imports from the former torcheeg.utils.file, torcheeg.utils.experiment, torcheeg.utils.cache and torcheeg.utils.lazy_loader submodules with imports from torcheeg.utils. For example:

from torcheeg.utils import LazyLoader, download_url, ensure_cache

Plotting functions now live in torcheeg.visualizers. Replace plotting imports from torcheeg.utils or torcheeg.utils.visualize with imports from torcheeg.visualizers. No domain-specific utils.py file is renamed or moved.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources