ClassificationLogger Class
ml_debugger.monitoring.classification.classification_torchlogger.ClassificationTorchLogger
Bases: MonitoringLogger, ClassificationTorchTracer
Logger for classification tasks using PyTorch models.
__init__(model, model_name, version_name, result_name=None, n_epoch='latest', target_layers=None, additional_fields=None, auto_sync=True, force_table_recreate=False, api_endpoint=None, api_key=None)
Initialize classification logger.
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[str]
|
The name of the existing evaluation result to retrieve. |
None
|
|
Union[str, Optional[int]]
|
Filter option for n_epoch value. |
'latest'
|
|
Optional[Dict[str, str]]
|
Mapping of layer aliases to module paths. |
None
|
|
Optional[List[dict]]
|
Extra fields for database schema. |
None
|
|
bool
|
Enable backgroup syncing of logged data. |
True
|
|
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, input_ids=None, dataset_type='deploying', **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[List[str]]
|
Identifiers of each input data. |
None
|
|
str
|
Identifier of input dataset. (e.g. 'train', 'val', 'test', 'deploying') |
'deploying'
|
|
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)
Export extracted features into a ZIP archive.
Uses the internal n_epoch resolved during validator setup to
filter records, consistent with upload() and wait_for_save().
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
|
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path to the created ZIP file, or None on non-primary distributed ranks. |