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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Module
|
PyTorch model to trace. |
required |
|
str
|
Name of the ML model. |
required |
|
str
|
Version identifier for the ML model. |
required |
|
Optional[Dict[str, str]]
|
Mapping of layer aliases to module paths. |
None
|
|
Optional[List[dict]]
|
Extra fields for database schema. |
None
|
|
Optional[List[dict]]
|
Extra fields for groundtruth database schema. |
None
|
|
bool
|
Enable backgroup syncing of logged data. |
False
|
|
bool
|
Whether to drop and recreate existing tables. |
False
|
|
Optional[str]
|
URL of the service API for data upload. |
None
|
|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Any
|
Input data for the model inference. |
required |
|
Optional[Any]
|
Optional ground truth corresponding to input. |
required |
|
List[str]
|
Identifiers of each input data. |
required |
|
str
|
Identifier of input dataset. (e.g. 'train', 'val', 'test', 'deploying') |
'train'
|
|
Optional[int]
|
Number identifier of training iteration. |
None
|
|
Any
|
Additional keyword arguments for parsing and saving I/O data. (will be passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The raw output produced by the model. |
Raises:
| Type | Description |
|---|---|
Any
|
Propagates exceptions from parsing and saving operations. |
get_hooked_features(layer_name)
Retrieve the captured output for a given layer alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Alias of the layer whose activation was captured. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Activation data stored for the specified layer. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no activation has been captured for |
export(output_path=None, n_epoch=None)
Export extracted features and ground truth data into a ZIP archive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Optional[str]
|
Path or directory for saving the ZIP file. If no .zip extension, the default filename is appended. Defaults to cwd. |
None
|
|
Optional[int]
|
Target epoch number. If None, exports all epochs. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path to the created ZIP file, or None on non-primary distributed ranks. |