PaddlePaddle / InterpretDL

InterpretDL: Interpretation of Deep Learning Models,基于『飞桨』的模型可解释性算法库。
https://interpretdl.readthedocs.io
Apache License 2.0
237 stars 38 forks source link

UFuncTypeError: Cannot cast ufunc 'add' output from dtype('O') to dtype('float64') with casting rule 'same_kind' #69

Closed rojinakashefi closed 10 months ago

rojinakashefi commented 10 months ago

This is my code: `!pip install paddlepaddle-gpu !git clone https://github.com/PaddlePaddle/InterpretDL.git import os import sys os.chdir(/content/InterpretDL) sys.path.insert(0, os.getcwd()) import interpretdl as it !wget -c https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_224_pretrained.pdparams -P /content/InterpretDL/tutorials/assets/ from tutorials.assets.vision_transformer import ViT_base_patch16_224 paddle_model = ViT_base_patch16_224() MODEL_PATH = /content/InterpretDL/tutorials/assets/ViT_base_patch16_224_pretrained.pdparams paddle_model.state_dict(paddle.load(MODEL_PATH)) img_path = /content/InterpretDL/imgs/catdog.jpg tam = it.TAMInterpreter(paddle_model) heatmap = tam.interpret( img_path, start_layer=4, label=None, # cat visual=True, save_path=None)' But i keep getting this error: UFuncTypeError: Cannot cast ufunc 'add' output from dtype('O') to dtype('float64') with casting rule 'same_kind' why?

rojinakashefi commented 10 months ago

the problem is from transition_attention_maps.py predict_fn function where attns[-1].grad is None, however i don't know how to fix it

holyseven commented 10 months ago

see if this solves this issue, https://github.com/PaddlePaddle/InterpretDL/issues/52.

let me know if it does not work.

rojinakashefi commented 10 months ago

I am using google colab environment trying to install paddle 2.3.2 for python3.10 form this link cpu version. however when i import paddle i get this error: Error: Can not import avx core while this file exists: /usr/local/lib/python3.10/dist-packages/paddle/fluid/core_avx.so

rojinakashefi commented 10 months ago

版本&环境信息 Version & Environment Information Paddle version: N/A Paddle With CUDA: N/A

OS: ubuntu 22.04 GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Clang version: 14.0.0-1ubuntu1.1 CMake version: version 3.27.7 Libc version: glibc 2.35 Python version: 3.10.12

CUDA version: 11.8.89 Build cuda_11.8.r11.8/compiler.31833905_0 cuDNN version: 8.9.6 Nvidia driver version: N/A

holyseven commented 10 months ago

try python -m pip install --force-reinstall paddlepaddle==2.3.2 for the paddle installation issue. Or create a new env to install paddlepaddle

rojinakashefi commented 10 months ago

the thing is paddlepaddle==2.3.2 can't be installed in ubuntu 22.4 and requires ubuntu lower than 20.4.