WandbEvalCallback
4 minute read
Abstract base class to build Keras callbacks for model prediction visualization.
You can build callbacks for visualizing model predictions on_epoch_end
that can be passed to model.fit()
for classification, object detection,
segmentation, etc. tasks.
To use this, inherit from this base callback class and implement the
add_ground_truth
and add_model_prediction
methods.
The base class will take care of the following:
- Initialize
data_table
for logging the ground truth andpred_table
for predictions. - The data uploaded to
data_table
is used as a reference for thepred_table
. This is to reduce the memory footprint. Thedata_table_ref
is a list that can be used to access the referenced data. Check out the example below to see how it’s done. - Log the tables to W&B as W&B Artifacts.
- Each new
pred_table
is logged as a new version with aliases.
Example:
To have more fine-grained control, you can override the on_train_begin
and
on_epoch_end
methods. If you want to log the samples after N batched, you
can implement on_train_batch_end
method.
Methods
add_ground_truth
Add ground truth data to data_table
.
Use this method to write the logic for adding validation/training data to
data_table
initialized using init_data_table
method.
Example:
This method is called once on_train_begin
or equivalent hook.
add_model_predictions
Add a prediction from a model to pred_table
.
Use this method to write the logic for adding model prediction for validation/
training data to pred_table
initialized using init_pred_table
method.
Example:
This method is called on_epoch_end
or equivalent hook.
init_data_table
Initialize the W&B Tables for validation data.
Call this method on_train_begin
or equivalent hook. This is followed by adding
data to the table row or column wise.
Args | |
---|---|
column_names |
(list) Column names for W&B Tables. |
init_pred_table
Initialize the W&B Tables for model evaluation.
Call this method on_epoch_end
or equivalent hook. This is followed by adding
data to the table row or column wise.
Args | |
---|---|
column_names |
(list) Column names for W&B Tables. |
log_data_table
Log the data_table
as W&B artifact and call use_artifact
on it.
This lets the evaluation table use the reference of already uploaded data (images, text, scalar, etc.) without re-uploading.
Args | |
---|---|
name |
(str) A human-readable name for this artifact, which is how you can identify this artifact in the UI or reference it in use_artifact calls. (default is ‘val’) |
type |
(str) The type of the artifact, which is used to organize and differentiate artifacts. (default is ‘dataset’) |
table_name |
(str) The name of the table as will be displayed in the UI. (default is ‘val_data’). |
log_pred_table
Log the W&B Tables for model evaluation.
The table will be logged multiple times creating new version. Use this to compare models at different intervals interactively.
Args | |
---|---|
type |
(str) The type of the artifact, which is used to organize and differentiate artifacts. (default is ’evaluation’) |
table_name |
(str) The name of the table as will be displayed in the UI. (default is ’eval_data') |
aliases |
(List[str]) List of aliases for the prediction table. |
set_model
set_params
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.