tf-keras-vis icon indicating copy to clipboard operation
tf-keras-vis copied to clipboard

cannot use BinaryScore

Open rEstela opened this issue 2 years ago • 3 comments

Hi, Thank you for this git! Is fantastic.

I'm having problems tying to use this for binary classification.

Can you show an example using it?

rEstela avatar Mar 04 '22 12:03 rEstela

Please refer the page below:

https://keisen.github.io/tf-keras-vis-docs/api/tf_keras_vis.utils.scores.html#binary-classification-task

Thanks!

keisen avatar Mar 04 '22 14:03 keisen

Thank you, This is what I was looking for. Somehow didn't see these instructions O.o

I tried to use it on a simpler example (cat and dog binary classification) and it worked!

My problem now is when i have nested models...

Model1

Model2_1

Model2_2

I used the code:

score = BinaryScore(1.0)

replace2linear = ReplaceToLinear()

gradcam = Gradcam(model, model_modifier=replace2linear, clone=True)

cam = gradcam(score, x_img, penultimate_layer=-1)

But i got the following error:

ValueError: Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, 141, 898, 1), dtype=tf.float32, name='conv2d_12_input'), name='conv2d_12_input', description="created by layer 'conv2d_12_input'") at layer "conv2d_12". The following previous layers were accessed without issue: []

If i do:

model2 = model2 = model.layers[1]

I have:

ValueError: output shape must be (batch_size, 1), but was (1, 64)

rEstela avatar Mar 04 '22 17:03 rEstela

I face the same Graph disconnected error

IshaanShettigar avatar Aug 16 '23 18:08 IshaanShettigar