Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass transforms for optimized automl model explanations and improve error logging to include inner exception #2269

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
import json
import pickle
import traceback
import warnings
from pathlib import Path
from typing import Any, List, Optional
Expand Down Expand Up @@ -120,12 +121,15 @@ def __init__(self, model: Any,
automl_wrapper = python_model._model
inner_model = automl_wrapper._model
number_of_classes = automl_wrapper._number_of_classes
transforms = automl_wrapper.get_inference_transform()
self._model = PytorchDRiseWrapper(
inner_model, number_of_classes, device=device)
except Exception as e:
inner_model, number_of_classes, device=device,
transforms=transforms)
except Exception:
tb = traceback.format_exc()
warnings.warn(("Could not extract inner automl model." +
"Explanation may take longer to compute." +
"Inner exception: {}").format(str(e)),
"Inner exception: {}").format(tb),
UserWarning)
self._model = MLflowDRiseWrapper(model._model, classes)
else:
Expand Down Expand Up @@ -299,6 +303,10 @@ def compute_single_explanation(self,
return fl
b64_string = fl[object_index]
except BaseException:
tb = traceback.format_exc()
warnings.warn(("Could not generate saliency map. " +
"Inner exception: {}").format(tb),
UserWarning)
if object_index is None:
return [self._get_fail_str()]
b64_string = self._get_fail_str()
Expand Down
Loading