johnb110 / VDPython

VulDeePecker algorithm implemented in Python
104 stars 43 forks source link

代码运行需要什么样的 python环境 #2

Open xiaohuihui1024 opened 4 years ago

xiaohuihui1024 commented 4 years ago

使用 Tensorflow 2.x 作为 keras 后端,报如下错误

Traceback (most recent call last):
  File ".\vuldeepecker.py", line 100, in <module>
    main()
  File ".\vuldeepecker.py", line 96, in main
    blstm.train()
  File "xxx\blstm.py", line 72, in train
    epochs=4, class_weight=self.class_weight)
  File "C:\Anaconda\Lib\site-packages\tensorflow\python\keras\engine\training.py", line 66, in _method_wrapper
    return method(self, *args, **kwargs)
  File "C:\Anaconda\Lib\site-packages\tensorflow\python\keras\engine\training.py", line 815, in fit
    model=self)
  File "C:\Anaconda\Lib\site-packages\tensorflow\python\keras\engine\data_adapter.py", line 1124, in __init__
    if class_weight:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
lily79 commented 4 years ago

这个貌似不是环境的错误,是代码的问题,在BLSTM模块里,vectors和labels弄错了,我把 vectors = np.stack(data.iloc[:, 1].values)改成了 vectors = np.stack(data.iloc[:, 0].values),labels的处理类似,也报了你一样的错误。你这里已经改过来了吧?是改的iloc参数,还是直接把vectors和labels对调了?