Skip to content

Commit

Permalink
Merge pull request #84 from kundajelab/AvantiShri-patch-2
Browse files Browse the repository at this point in the history
Scores on multiple task with same shuffref
  • Loading branch information
AvantiShri authored Jan 7, 2020
2 parents c248136 + 3fc82db commit 4869415
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion deeplift.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: deeplift
Version: 0.6.9.1
Version: 0.6.9.2
Summary: DeepLIFT (Deep Learning Important FeaTures)
Home-page: https://github.com/kundajelab/deeplift
License: UNKNOWN
Expand Down
41 changes: 26 additions & 15 deletions deeplift/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,32 @@ def compute_scores_with_shuffle_seq_refs(
input_shape=tuple(input_shape)
input_data_list = [np.reshape(np.asarray(to_run_input_data_seqs),input_shape)]
input_references_list = [np.reshape(np.asarray(to_run_input_data_refs),input_shape)]
computed_scores = np.array(score_computation_function(
task_idx=task_idx,
input_data_list=input_data_list,
input_references_list=input_references_list,
batch_size=batch_size,
progress_update=progress_update))
computed_scores = np.reshape(
computed_scores,
[len(input_data_sequences),
num_refs_per_seq]
+list(input_data_list[0].shape[1:]))

#take the mean over all the refs
mean_scores = np.mean(computed_scores,axis=1)
return mean_scores
#wrap task_idx in a list if it was not in a list
# (will unwrap later)
if (hasattr(task_idx, '__iter__')) == False:
list_wrapped_task_idx = [task_idx]
else:
list_wrapped_task_idx = task_idx
the_scores = []
for a_task in list_wrapped_task_idx:
computed_scores = np.array(score_computation_function(
task_idx=a_task,
input_data_list=input_data_list,
input_references_list=input_references_list,
batch_size=batch_size,
progress_update=progress_update))
computed_scores = np.reshape(
computed_scores,
[len(input_data_sequences),
num_refs_per_seq]
+list(input_data_list[0].shape[1:]))
#take the mean over all the refs
mean_scores = np.mean(computed_scores,axis=1)
the_scores.append(mean_scores)
#unwrap the scores if task_idx was not orginally a list
if (hasattr(task_idx, '__iter__')) == False:
the_scores = the_scores[0]
return the_scores
return compute_scores_with_shuffle_seq_refs


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Implements the methods in "Learning Important Features Through Propagating Activation Differences" by Shrikumar, Greenside & Kundaje, as well as other commonly-used methods such as gradients, guided backprop and integrated gradients. See https://github.com/kundajelab/deeplift for documentation and FAQ.
""",
url='https://github.com/kundajelab/deeplift',
version='0.6.9.1',
version='0.6.9.2',
packages=['deeplift',
'deeplift.layers', 'deeplift.visualization',
'deeplift.conversion'],
Expand Down

0 comments on commit 4869415

Please sign in to comment.