DanielLin1986 / Function-level-Vulnerability-Detection

A deep learning-based vulnerability detection framework
71 stars 23 forks source link

AttributeError: 'NoneType' object has no attribute 'get' #18

Open aravinthk00 opened 2 years ago

aravinthk00 commented 2 years ago

I try to test the trained model but I getting error , given below my error log :

(myenv) C:\Users\30863\Function-level-Vulnerability-Detection-master>Python main.py --config config\config.yaml --test --trained_model C:\Users\30863\Function-level-Vulnerability-Detection-master\result\models\test_model_01_0.920_0.334828.h5 Using TensorFlow backend. 2022-08-09 14:51:29.072700: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_100.dll'; dlerror: cudart64_100.dll not found 2022-08-09 14:51:29.072841: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. [INFO] Start testing process.... [INFO] Loading data from C:\Users\30863\Function-level-Vulnerability-Detection-master\data/.... [INFO] The length of the loaded data list is : 622 [INFO] Pad the sequence to unified length... [INFO] Patition the data .... [INFO] There are 125 total samples in the test set. 9 vulnerable samples. WARNING:tensorflow:From C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\backend\tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

Traceback (most recent call last): File "main.py", line 34, in helper.exec() File "C:\Users\30863\Function-level-Vulnerability-Detection-master\src\helper.py", line 345, in exec model = self.modelLoader() File "C:\Users\30863\Function-level-Vulnerability-Detection-master\src\helper.py", line 112, in modelLoader trained_model = load_model(trained_model_path) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\saving.py", line 225, in _deserialize_model model = model_from_config(model_config, custom_objects=custom_objects) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\saving.py", line 458, in model_from_config return deserialize(config, custom_objects=custom_objects) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\layers__init.py", line 55, in deserialize printable_module_name='layer') File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object list(custom_objects.items()))) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\network.py", line 1022, in from_config process_layer(layer_data) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\network.py", line 1008, in process_layer custom_objects=custom_objects) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\layers\init__.py", line 55, in deserialize printable_module_name='layer') File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object list(custom_objects.items()))) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\layers\core.py", line 732, in from_config printable_module_name='function in Lambda layer') File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\utils\generic_utils.py", line 162, in deserialize_keras_object fn = module_objects.get(function_name) AttributeError: 'NoneType' object has no attribute 'get'

DanielLin1986 commented 2 years ago

I try to test the trained model but I getting error , given below my error log :

(myenv) C:\Users\30863\Function-level-Vulnerability-Detection-master>Python main.py --config config\config.yaml --test --trained_model C:\Users\30863\Function-level-Vulnerability-Detection-master\result\models\test_model_01_0.920_0.334828.h5 Using TensorFlow backend. 2022-08-09 14:51:29.072700: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_100.dll'; dlerror: cudart64_100.dll not found 2022-08-09 14:51:29.072841: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. [INFO] Start testing process.... [INFO] Loading data from C:\Users\30863\Function-level-Vulnerability-Detection-master\data/.... [INFO] The length of the loaded data list is : 622 [INFO] Pad the sequence to unified length... [INFO] Patition the data .... [INFO] There are 125 total samples in the test set. 9 vulnerable samples. WARNING:tensorflow:From C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\backend\tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

Traceback (most recent call last): File "main.py", line 34, in helper.exec() File "C:\Users\30863\Function-level-Vulnerability-Detection-master\src\helper.py", line 345, in exec model = self.modelLoader() File "C:\Users\30863\Function-level-Vulnerability-Detection-master\src\helper.py", line 112, in modelLoader trained_model = load_model(trained_model_path) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\saving.py", line 225, in _deserialize_model model = model_from_config(model_config, custom_objects=custom_objects) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\saving.py", line 458, in model_from_config return deserialize(config, custom_objects=custom_objects) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\layersinit.py", line 55, in deserialize printable_module_name='layer') File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object list(custom_objects.items()))) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\network.py", line 1022, in from_config process_layer(layer_data) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\engine\network.py", line 1008, in process_layer custom_objects=custom_objects) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\layersinit.py", line 55, in deserialize printable_module_name='layer') File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object list(custom_objects.items()))) File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\layers\core.py", line 732, in from_config printable_module_name='function in Lambda layer') File "C:\Users\30863\Anaconda3\envs\myenv\lib\site-packages\keras\utils\generic_utils.py", line 162, in deserialize_keras_object fn = module_objects.get(function_name) AttributeError: 'NoneType' object has no attribute 'get'

As was mentioned in another issue, the ELMo module which was saved in a directory cannot be loaded for testing. I do not know why and I cannot find a solution.

To perform testing, please test the model immediately after the training process.

lihuiuyun commented 2 years ago

have you sloved this problem?

aravinthk00 commented 2 years ago

Not yet.have you solution ?

lihuiuyun commented 2 years ago

no.Is there any special operation to test the model immediately after the training process?i test it immediately but still have the same problem.