wandb

fgvc.utils.wandb.finish_wandb() str

Finish W&B run.

The method is executed if the W&B run was initialized.

Returns:

W&B run id.

Return type:

run_id

fgvc.utils.wandb.get_runs_df(entity: str, project: str, config_cols: List[str] = None, summary_cols: List[str] = None) DataFrame

Get a DataFrame with W&B runs for the given entity/project.

The method is executed if the W&B library is installed.

Parameters:
  • entity – Name of W&B entity.

  • project – Name of W&B project.

  • config_cols – Columns from W&B run configuration to include into the DataFrame.

  • summary_cols – Columns from W&B run summary to include into the DataFrame.

Return type:

A DataFrame with W&B runs.

fgvc.utils.wandb.if_wandb_is_installed(func: callable)

A decorator function that checks if the W&B library is installed.

fgvc.utils.wandb.if_wandb_run_started(func: callable)

A decorator function that checks if a W&B run is initialized.

fgvc.utils.wandb.init_wandb(config: dict, run_name: str, entity: str, project: str, *, tags: list = None, notes: str = None, **kwargs) None

Initialize a new W&B run.

The method is executed if the W&B library is installed.

Parameters:
  • config – A dictionary with experiment configuration. Keys like “tags” and “notes” in the config dictionary are passed to W&B init method as arguments.

  • run_name – Name of W&B run.

  • entity – Name of W&B entity.

  • project – Name of W&B project.

  • tags – A list of strings that populates tags of the run in W&B UI.

  • notes – A longer description of the W&B run.

Return type:

W&B Run instance.

fgvc.utils.wandb.log_artifact(run_or_path: str | None, artifact: None, aliases: List[str] = None)

Log artifact to W&B run, after the W&B run is finished.

Parameters:
  • run_or_path – A W&B api run or path to run in the form entity/project/run_id.

  • artifact – W&B Artifact.

  • aliases – List of Artifact tags.

fgvc.utils.wandb.log_progress(epoch: int, *, scores: dict = None, train_scores: dict = None, valid_scores: dict = None, train_loss: float = None, valid_loss: float = None, lr: float = None, max_grad_norm: float = None, commit: bool = True, train_prefix: str = 'Train/', valid_prefix: str = 'Valid/')

Log a dictionary with scores or other data to W&B run.

The scores in arguments are combined into a single dictionary in the following order: 1. train_scores and valid_scores 2. scores 3. train_loss, valid_loss, lr, max_grad_norm

The method is executed if the W&B run was initialized.

Parameters:
  • epoch – Current training epoch.

  • scores – A dictionary with scores or other data to log.

  • train_scores – A dictionary with training scores or other data to log with train/ prefix.

  • valid_scores – A dictionary with validation scores or other data to log with valid/ prefix.

  • train_loss – Training loss.

  • valid_loss – Validation loss.

  • lr – Learning rate.

  • max_grad_norm – Maximum gradient norm.

  • commit – If true save the scores to the W&B and increment the step. Otherwise, only update the current score dictionary.

  • train_prefix – Prefix string to include in the name of training scores.

  • valid_prefix – Prefix string to include in the name of validation scores.

fgvc.utils.wandb.log_summary_scores(run_or_path: str | None, scores: dict, *, allow_new: bool = True, prefix: str = 'Test/')

Log scores to W&B run summary, after the W&B run is finished.

The method is executed if the W&B library is installed.

Parameters:
  • run_or_path – A W&B api run or path to run in the form entity/project/run_id.

  • scores – A dictionary of scores to update in the W&B run summary.

  • allow_new – If false the method checks if each passed score already exists in W&B run summary and raises ValueError if the score does not exist.

  • prefix – Prefix string to include in the name of test scores.

fgvc.utils.wandb.resume_wandb(run_id: int, entity: str, project: str) None

Resume an existing W&B run.

Parameters:
  • run_id – ID of W&B run.

  • entity – Name of W&B entity.

  • project – Name of W&B project.

Return type:

W&B Run instance.

fgvc.utils.wandb.set_best_scores_in_summary(run_or_path: str | None, primary_score: str, scores: list | callable)

Update W&B run summary with the best validation scores instead of the last epoch scores.

The method is executed if the W&B library is installed.

Parameters:
  • run_or_path – A W&B api run or path to run in the form entity/project/run_id.

  • primary_score – A score in the W&B run history based on which the best epoch is selected.

  • scores – A list of score to update in the W&B run summary.