@@ -72,7 +72,7 @@ def __init__(
7272
7373 """
7474 # first, we need to find the framework
75- if type (model ) is tuple :
75+ if isinstance (model , tuple ) :
7676 a , b = model
7777 try :
7878 a .named_parameters ()
@@ -517,7 +517,7 @@ def __init__(
517517 with torch .no_grad ():
518518 _ = model (* data )
519519 interim_inputs = self .layer .target_input
520- if type (interim_inputs ) is tuple :
520+ if isinstance (interim_inputs , tuple ) :
521521 # this should always be true, but just to be safe
522522 self .data = [i .clone ().detach () for i in interim_inputs ]
523523 else :
@@ -664,13 +664,12 @@ def shap_values(
664664 _ = self .model (* [samples_input [a ][k ].unsqueeze (0 ) for a in range (len (X ))])
665665 interim_inputs = self .layer .target_input # type: ignore[union-attr]
666666 del self .layer .target_input # type: ignore[union-attr]
667- if type (interim_inputs ) is tuple :
668- if type (interim_inputs ) is tuple :
669- # this should always be true, but just to be safe
670- for a in range (len (interim_inputs )):
671- samples_delta [a ][k ] = interim_inputs [a ].cpu ().numpy ()
672- else :
673- samples_delta [0 ][k ] = interim_inputs .cpu ().numpy () # type: ignore[attr-defined]
667+ if isinstance (interim_inputs , tuple ):
668+ # this should always be true, but just to be safe
669+ for a in range (len (interim_inputs )):
670+ samples_delta [a ][k ] = interim_inputs [a ].cpu ().numpy ()
671+ else :
672+ samples_delta [0 ][k ] = interim_inputs .cpu ().numpy () # type: ignore[attr-defined]
674673
675674 # compute the gradients at all the sample points
676675 find = model_output_ranks [j , i ]
0 commit comments