コンテンツにスキップ

ClassificationTracer Class

ml_debugger.training.classification.classification_torchtracer.ClassificationTrainingTorchTracer

Bases: TrainingTracer, ClassificationTorchTracer

TrainingTracer for classification tasks using PyTorch models.

__init__(model, model_name, version_name, target_layers=None, additional_fields=None, additional_label_fields=None, auto_sync=False, force_table_recreate=False, api_endpoint=None, api_key=None)

Initialize classification tracer.

引数:

名前 タイプ デスクリプション デフォルト

model

Module

PyTorch model to trace.

必須

model_name

str

Name of the ML model.

必須

version_name

str

Version identifier for the ML model.

必須

target_layers

Optional[Dict[str, str]]

Mapping of layer aliases to module paths.

None

additional_fields

Optional[List[dict]]

Extra fields for database schema.

None

additional_label_fields

Optional[List[dict]]

Extra fields for groundtruth database schema.

None

auto_sync

bool

Enable backgroup syncing of logged data.

False

force_table_recreate

bool

Whether to drop and recreate existing tables.

False

api_endpoint

Optional[str]

URL of the service API for data upload.

None

api_key

Optional[str]

API key for authenticating with the service.

None

__call__(model_input, ground_truth, input_ids, dataset_type='train', n_epoch=None, **kwargs)

Invoke the tracer on a single inference, recording I/O data.

引数:

名前 タイプ デスクリプション デフォルト

model_input

Any

Input data for the model inference.

必須

ground_truth

Optional[Any]

Optional ground truth corresponding to input.

必須

input_ids

List[str]

Identifiers of each input data.

必須

dataset_type

str

Identifier of input dataset. (e.g. 'train', 'val', 'test', 'deploying')

'train'

n_epoch

Optional[int]

Number identifier of training iteration.

None

**kwargs

Any

Additional keyword arguments for parsing and saving I/O data. (will be passed to self._parse_and_save_io_data)

{}

戻り値:

名前 タイプ デスクリプション
Any Any

The raw output produced by the model.

発生:

タイプ デスクリプション
Any

Propagates exceptions from parsing and saving operations.

get_hooked_features(layer_name)

Retrieve the captured output for a given layer alias.

引数:

名前 タイプ デスクリプション デフォルト

layer_name

str

Alias of the layer whose activation was captured.

必須

戻り値:

名前 タイプ デスクリプション
Any Any

Activation data stored for the specified layer.

発生:

タイプ デスクリプション
KeyError

If no activation has been captured for layer_name.

export(output_path=None, n_epoch=None)

Export extracted features and ground truth data into a ZIP archive.

引数:

名前 タイプ デスクリプション デフォルト

output_path

Optional[str]

Path or directory for saving the ZIP file. If no .zip extension, the default filename is appended. Defaults to cwd.

None

n_epoch

Optional[int]

Target epoch number. If None, exports all epochs.

None

戻り値:

タイプ デスクリプション
Optional[Path]

Path to the created ZIP file, or None on non-primary distributed ranks.

wait_for_save(n_epoch=None, interval=3)

upload(n_epoch=None)