-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Report
The crested.tl._explainer.integrated_grad
function will fail silently (producing 0 as output)
when the data type of the input is not a floating point.
The functions: crested.tl._explainer.saliency_map
and crested.tl._explainer.smoothgrad
at least give some warning.
import keras
import crested
import numpy as np
from crested.utils._seq_utils import one_hot_encode_sequence
from crested.tl._explainer import integrated_grad, saliency_map, smoothgrad
import random
model_path, output_names_biccn = crested.get_model("DeepBICCN")
model_biccn = keras.models.load_model(model_path)
random.seed(123)
oh = one_hot_encode_sequence("".join(random.choices(["A", "C", "G", "T"], k=model_biccn.input[0].shape[1]))).astype(np.uint8)
integrated_grad(oh, model_biccn, 1).sum()
#0
saliency_map(oh, model_biccn, 1).sum()
#WARNING:tensorflow:The dtype of the watched tensor must be floating (e.g. tf.float32), got tf.uint8
#AttributeError: 'NoneType' object has no attribute 'numpy'
smoothgrad(oh, model_biccn, 1).sum()
#InvalidArgumentError: cannot compute AddV2 as input #1(zero-based) was expected to be a uint8 tensor but is a float tensor [Op:AddV2] name
Version information
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working