gensbi.recipes.utils#
Attributes#
Functions#
|
Resolve ID embeddings by strategy name. |
|
Build an EDM-family diffusion path from an SDE type string and config. |
|
Build a score-matching path from an SDE type string and config. |
|
|
|
|
|
|
|
Parse training and optimizer configuration from a YAML config file. |
|
|
|
Scale learning rate based on batch size using square root scaling. |
Module Contents#
- gensbi.recipes.utils._resolve_embedding_ids(dim, strategy, semantic_id)[source]#
Resolve ID embeddings by strategy name.
- Parameters:
dim (int or tuple of int) – Dimension specification (number of tokens, or (H, W) for 2D images).
strategy (str) – Embedding strategy name (e.g., “absolute”, “pos1d”, “rope1d”, “pos2d”, “rope2d”).
semantic_id (int) – Semantic identifier for the token group (0=obs, 1=cond).
- Returns:
ids (Array) – Token ID array.
resolved_dim (int) – Resolved flat dimension.
- Raises:
ValueError – If
strategyis not recognized.
- gensbi.recipes.utils.build_edm_path(sde, config)[source]#
Build an EDM-family diffusion path from an SDE type string and config.
- Parameters:
sde (str) – SDE type:
"EDM","VE", or"VP".config (dict) – Training configuration dict; scheduler hyperparameters are read from here with sensible defaults.
- Returns:
Configured diffusion path.
- Return type:
- Raises:
ValueError – If
sdeis not one of{"EDM", "VE", "VP"}.
- gensbi.recipes.utils.build_sm_path(sde_type, config)[source]#
Build a score-matching path from an SDE type string and config.
- Parameters:
sde_type (str) – SDE type:
"VP"or"VE".config (dict) – Training configuration dict; scheduler hyperparameters are read from here with sensible defaults.
- Returns:
Configured score-matching path.
- Return type:
- Raises:
ValueError – If
sde_typeis not one of{"VP", "VE"}.
- gensbi.recipes.utils.init_ids_1d(dim, semantic_id=None)[source]#
- Parameters:
dim (int)
semantic_id (Union[int, None])
- gensbi.recipes.utils.init_ids_2d(dim, semantic_id=0)[source]#
- Parameters:
dim (Tuple[int, int])
semantic_id (int)
- gensbi.recipes.utils.init_ids_joint(dim_obs, dim_cond)[source]#
- Parameters:
dim_obs (int)
dim_cond (int)
- gensbi.recipes.utils.parse_training_config(config_path)[source]#
Parse training and optimizer configuration from a YAML config file.
Reads the
trainingandoptimizersections of the config and returns a flat dictionary consumed byAbstractPipeline.- Parameters:
config_path (str) – Path to the YAML configuration file.
- Returns:
training_config – Parsed training configuration dictionary.
- Return type:
dict
- gensbi.recipes.utils.scale_lr(batch_size, base_lr=0.0001, reference_batch_size=256)[source]#
Scale learning rate based on batch size using square root scaling.
- Parameters:
batch_size (int) – The current batch size.
base_lr (float) – The base learning rate for the reference batch size.
reference_batch_size (int, optional) – The reference batch size. Defaults to 256.
- Returns:
The adjusted learning rate.
- Return type:
float