mskspi / PathCNN

Interpretable convolutional neural networks on multi-omics data predict long-term survival in glioblastoma
13 stars 8 forks source link

Issue in PathCNN_GradCAM.py #3

Closed JingwenD closed 1 year ago

JingwenD commented 2 years ago

Hi, I got an issue when running the PathCNN_GradCAM.py as follow:

dropout_330
dropout_330
Traceback (most recent call last):

  File "<ipython-input-246-18f09e0baee6>", line 1, in <module>
    runfile('/home/jdeng/Project/2_RNAseqSkin/multiOmics/PathCNN-main/PathCNN_GradCAM.py', wdir='/home/jdeng/Project/2_RNAseqSkin/multiOmics/PathCNN-main')

  File "/usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "/usr/lib/python3/dist-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/home/jdeng/Project/2_RNAseqSkin/multiOmics/PathCNN-main/PathCNN_GradCAM.py", line 150, in <module>
    get_output[target_class] = grad_cam(model, target_class, layer.name)

  File "/home/jdeng/Project/2_RNAseqSkin/multiOmics/PathCNN-main/PathCNN_GradCAM.py", line 14, in grad_cam
    y_c = model.output.op.inputs[0][0, category_index]

  File "/home/jdeng/.local/lib/python3.8/site-packages/keras/engine/keras_tensor.py", line 233, in op
    raise TypeError('Keras symbolic inputs/outputs do not '

TypeError: Keras symbolic inputs/outputs do not implement `op`. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.

I google this issue but still fail to fix it.

Best,

Jingwen

taznux commented 2 years ago

We used old versions of TensorFlow and Keras like below. tensorflow==2.0 keras==2.3 h5py<3.0.0 Please check your versions and try our google notebook. https://colab.research.google.com/drive/1WCfguKFN0Zs0ZDkKga2DpDgjBP3PnwB_?usp=sharing

taznux commented 2 years ago

When you test your model using PathCNN_GradCAM.py Your model should be like below.

Model: "model_1"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_1 (InputLayer)         (None, 146, 6, 1)         0         
_________________________________________________________________
conv2d_1 (Conv2D)            (None, 146, 6, 32)        320       
_________________________________________________________________
conv2d_2 (Conv2D)            (None, 146, 6, 64)        18496     
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 36, 3, 64)         0         
_________________________________________________________________
dropout_1 (Dropout)          (None, 36, 3, 64)         0         
_________________________________________________________________
flatten_1 (Flatten)          (None, 6912)              0         
_________________________________________________________________
dense_1 (Dense)              (None, 64)                442432    
_________________________________________________________________
dropout_2 (Dropout)          (None, 64)                0         
_________________________________________________________________
dense_2 (Dense)              (None, 2)                 130       
=================================================================

If you run the code using spyder or pycharm in the debug mode or some session like that. The model would be generated with increased numbering every time you restart. Please run the modeling code using run a script or run the script from a terminal.