foxai.callbacks package
Submodules
foxai.callbacks.wandb_callback module
Callback for Weights and Biases.
- class foxai.callbacks.wandb_callback.WandBCallback(wandb_logger: WandbLogger, explainers: List[ExplainerWithParams], idx_to_label: Dict[int, str], max_artifacts: int = 3)[source]
Bases:
Callback
Library callback for Weights and Biases.
- explain(model: LightningModule, item: Tensor, target_label: Tensor, attributes_dict: Dict[str, List[ndarray]], caption_dict: Dict[str, List[str]], figures_dict: Dict[str, List[Figure]]) Tuple[Dict[str, List[ndarray]], Dict[str, List[str]], Dict[str, List[Figure]]] [source]
Calculate explainer attributes, creates captions and figures.
- Parameters:
model – Model to explain.
item – Input data sample tensor.
target_label – Sample label.
attributes_dict – List of attributes for every explainer and sample.
caption_dict – List of captions for every explainer and sample.
figures_dict – List of figures for every explainer and sample.
- Returns:
Tuple of maps containing attributes, captions and figures for every explainer and sample.
- iterate_dataloader(dataloader_list: List[DataLoader], max_items: int) Generator[Tuple[Tensor, Tensor], None, None] [source]
Iterate over dataloader list with constraint on max items returned.
- Parameters:
dataloader – Trainer dataloader.
max_items – Max items to return.
- Yields:
Tuple containing training sample and corresponding label.
- log_explanations(attributes_dict: Dict[str, List[ndarray]], caption_dict: Dict[str, List[str]], figures_dict: Dict[str, List[Figure]]) None [source]
Log explanation artifacts to W&B experiment.
- Parameters:
attributes_dict – Numpy array attributes for every sample and every explainer.
caption_dict – Caption for every sample and every explainer.
figures_dict – Figure with attributes for every sample and every explainer.