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

Fix small bug in deeplift wrapper #181

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 7 additions & 7 deletions innvestigate/analyzer/deeplift.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def _create_deep_lift_func(self):

with tempfile.NamedTemporaryFile(suffix=".hdf5") as f:
self._model.save(f.name)
deeplift_model = kc.convert_model_from_saved_files(
self._deeplift_model = kc.convert_model_from_saved_files(
f.name, nonlinear_mxts_mode=nonlinear_mxts_mode,
verbose=self._verbose)

Expand All @@ -316,18 +316,18 @@ def fix_name(s):
raise ValueError("Only a single output layer is supported.")
tmp = self._model.outputs[0]._keras_history
target_layer_name = fix_name(tmp[0].name+"_%i" % tmp[1])
self._func = deeplift_model.get_target_contribs_func(
self._deep_lift_func = self._deeplift_model.get_target_contribs_func(
find_scores_layer_name=score_layer_names,
pre_activation_target_layer_name=target_layer_name)
self._references = kutils.broadcast_np_tensors_to_keras_tensors(
self._model.inputs, self._reference_inputs)

def _analyze_with_deeplift(self, X, neuron_idx, batch_size):
return self._func(task_idx=neuron_idx,
input_data_list=X,
batch_size=batch_size,
input_references_list=self._references,
progress_update=1000000)
return self._deep_lift_func(task_idx=neuron_idx,
input_data_list=X,
batch_size=batch_size,
input_references_list=self._references,
progress_update=1000000)

def analyze(self, X, neuron_selection=None):
if not hasattr(self, "_deep_lift_func"):
Expand Down