phanein / deepwalk

DeepWalk - Deep Learning for Graphs
http://www.perozzi.net/projects/deepwalk/
Other
2.68k stars 825 forks source link

AttributeError: 'NoneType' object has no attribute 'nodes' #54

Open jiay302 opened 6 years ago

jiay302 commented 6 years ago

When I set --max-memory-data-size 0, it throws following errors: Number of nodes: 6301 Number of walks: 63010 Data size (walks*length): 2520400 Data size 2520400 is larger than limit (max-memory-data-size: 0). Dumping walks to disk. Walking... Traceback (most recent call last): File "D:\Python27\Scripts\deepwalk-script.py", line 11, in load_entry_point('deepwalk==1.0.1', 'console_scripts', 'deepwalk')() File "D:\Python27\lib\site-packages\deepwalk-1.0.1-py2.7.egg\deepwalk__main.py", line 162, in main process(args) File "D:\Python27\lib\site-packages\deepwalk-1.0.1-py2.7.egg\deepwalk__main__.py", line 83, in process num_workers=args.workers) File "D:\Python27\lib\site-packages\deepwalk-1.0.1-py2.7.egg\deepwalk\walks.py", line 85, in write_walks_todisk for file in executor.map(_write_walks_to_disk, args_list): File "D:\Python27\lib\site-packages\concurrent\futures_base.py", line 641, in result_iterator yield fs.pop().result() File "D:\Python27\lib\site-packages\concurrent\futures_base.py", line 462, in result return self.get_result() File "D:\Python27\lib\site-packages\concurrent\futures_base.py", line 414, in __get_result raise exception_type, self._exception, self._traceback AttributeError: 'NoneType' object has no attribute 'nodes' Is there someone can help me?

GTmac commented 6 years ago

Are you running DeepWalk on Windows? Seems it is the same issue as #18 and #53. Please try the solution in #53 and let me know if it works :)

jiay302 commented 6 years ago

I am running DeepWalk on Windows. I have the same issue as yours, I now have no solutions.

GTmac commented 6 years ago

Please try either of the following two options:

jiay302 commented 6 years ago

I am using Python 2, and future package is the latest.

jiay302 commented 6 years ago

It doesn't throw errors when I run DeepWalk on Ubuntu. @GTmac

GTmac commented 6 years ago

I do not have a Windows machine at this moment. Can you check the version of packages which appear in https://github.com/phanein/deepwalk/blob/master/requirements.txt? Are they the same under Ubuntu and Windows on your machine?

jiay302 commented 6 years ago

wheel and argparse are not the same, others are the same.

jiay302 commented 6 years ago

I have changed the version of wheel and argparse packages and made their version be the same as Ubuntu's. But it still throws errors when running it on Windows. @GTmac

MohsenFazaeli commented 6 years ago

I traced the error and it seems that in line 64 and 65 of module walks global __current_graph __current_graph = G variable current_graph is assigned as a global value but in line 53 in function _write_walks_to_disk of same module g = __current_graph current_graph is none. IDK how to solve it but this causes the null object error.

asdfhalkehflkajdhf commented 6 years ago

我认为,这是一个BUG,出现这个错误是因为变量并不能在多进程中共享,而且在程序中我并没有看到使用multiprocessing对变量__current_graph 进行多进程共享设置。我查看了python对多进程和多线程的支持,在老版本中两者的区分是混乱的。我使用的环境中最新的anacoda3 python3.6。

修改使用线程ThreadPoolExecutor,或是multiprocessing 设置进程共享变量,并没有出现任何错误。

当然对于python的多线程和多进程的效率我表示同情。@GTmac

GTmac commented 6 years ago

@asdfhalkehflkajdhf Nice insights! I will update the repo later to switch to multithreading.

usernamezcn commented 5 years ago

I am running DeepWalk on Windows. I have the same issue as yours, I now have no solutions.

I met your problem too. Have you solved it?

usernamezcn commented 5 years ago

I met your problem too, could you tell me how to solve it?I'm going crazy!

usernamezcn commented 5 years ago

我已经更改了wheel和argparse包的版本,并使它们的版本与Ubuntu相同。但是在Windows上运行它时仍然会抛出错误。@GTmac

have you ever solve it?

asdfhalkehflkajdhf commented 5 years ago

好久没有用过。 我记得不用手动更改,有一个环境配置文件,执行下就可以。

liuzhuchen

liuzhuchen@126.com | 签名由网易邮箱大师定制 On 3/25/2019 09:41,子辛notifications@github.com wrote:

我已经更改了wheel和argparse包的版本,并使它们的版本与Ubuntu相同。但是在Windows上运行它时仍然会抛出错误。@GTmac

have you ever solve it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

asdfhalkehflkajdhf commented 5 years ago
你这不是安装成功了吗? 运行错误就自己debug查下吧,这种错误大概率每个人都不一样。 我没遇到数据大小限制,还有AttributeError: 'NoneType' object has no attribute 'nodes' 已经说的很明白了,没有"nodes"属性,查下为什么 liuzhuchen

liuzhuchen@126.com | 签名由网易邮箱大师定制 On 3/25/2019 10:11,子辛notifications@github.com wrote:

好久没有用过。 我记得不用手动更改,有一个环境配置文件,执行下就可以。 | | liuzhuchen | | liuzhuchen@126.com | 签名由网易邮箱大师定制 On 3/25/2019 09:41,子辛notifications@github.com wrote: 我已经更改了wheel和argparse包的版本,并使它们的版本与Ubuntu相同。但是在Windows上运行它时仍然会抛出错误。@GTmac have you ever solve it? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

首先感谢回复,万分感谢 您说的是那个文件鸭?是main.py还是setup.py文件,刚开始用的是py2,出现了这个问题,改成py3之后这个问题还存在。在安装deepwalk的时候执行了,“pip install -r requirement.txt”和"python setup.py install"将deepwalk安装成功了,之后input数据库的时候就出错了,在执行测试文件karate.adjlist时,没有出现任何错误完美运行。但是执行blogcatalog.mat文件之后就会出现AttributeError: 'NoneType' object has no attribute 'nodes'。会不会是因为数据太大,进入了else语句之后出现的错误,错误提示中有 Data size (walks*length): 32998400 Data size 32998400 is larger than limit (max-memory-data-size: 0). Dumping walks to disk.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

usernamezcn commented 5 years ago

你这不是安装成功了吗? 运行错误就自己debug查下吧,这种错误大概率每个人都不一样。 我没遇到数据大小限制,还有AttributeError: 'NoneType' object has no attribute 'nodes' 已经说的很明白了,没有"nodes"属性,查下为什么 | | liuzhuchen | | liuzhuchen@126.com | 签名由网易邮箱大师定制 On 3/25/2019 10:11,子辛notifications@github.com wrote: 好久没有用过。 我记得不用手动更改,有一个环境配置文件,执行下就可以。 | | liuzhuchen | | liuzhuchen@126.com | 签名由网易邮箱大师定制 On 3/25/2019 09:41,子辛notifications@github.com wrote: 我已经更改了wheel和argparse包的版本,并使它们的版本与Ubuntu相同。但是在Windows上运行它时仍然会抛出错误。@GTmac have you ever solve it? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread. 首先感谢回复,万分感谢 您说的是那个文件鸭?是main.py还是setup.py文件,刚开始用的是py2,出现了这个问题,改成py3之后这个问题还存在。在安装deepwalk的时候执行了,“pip install -r requirement.txt”和"python setup.py install"将deepwalk安装成功了,之后input数据库的时候就出错了,在执行测试文件karate.adjlist时,没有出现任何错误完美运行。但是执行blogcatalog.mat文件之后就会出现AttributeError: 'NoneType' object has no attribute 'nodes'。会不会是因为数据太大,进入了else语句之后出现的错误,错误提示中有 Data size (walks*length): 32998400 Data size 32998400 is larger than limit (max-memory-data-size: 0). Dumping walks to disk. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

oh no,have you ever seen the problem.The problem i met just as same as the author's.I do't think it's an accident

ikennaoluigbo commented 5 years ago

import logging from io import open from os import path from time import time from multiprocessing import cpu_count import random from concurrent.futures import ProcessPoolExecutor from collections import Counter from six.moves import zip import graph

logger = logging.getLogger("deepwalk") __current_graph = None __vertex2str = None

In the walk module of deepwalk, _current_graph and _vertex2str are both set to None as shown above. And as a result of this, I get this error "AttributeError: 'NoneType' object has no attribute "nodes" each time I run the codes. What is the solution to this please?

githubxiaowei commented 5 years ago

多进程不能共享变量,每个子进程里的 __current_graph 都是 None

githubxiaowei commented 5 years ago

in walks.py

from concurrent.futures import ThreadPoolExecutor as ProcessPoolExecutor

problem solved! XD

metehanunal commented 4 years ago

Hi,

I also have a PC with Windows 10. Even if "futures" package is the lastest version, I am getting the same error.

When I write: deepwalk --format mat --input example_graphs/blogcatalog.mat --max-memory-data-size 0 --number-walks 80 --representation-size 128 --walk-length 40 --window-size 10 --workers 1 --output example_graphs/blogcatalog.embeddings

I get:

Number of nodes: 10312
Number of walks: 824960
Data size (walks*length): 32998400
Data size 32998400 is larger than limit (max-memory-data-size: 0).  Dumping walks to disk.
Walking...
Traceback (most recent call last):
  File "C:\Python27\Scripts\deepwalk-script.py", line 11, in <module>
    load_entry_point('deepwalk==1.0.3', 'console_scripts', 'deepwalk')()
  File "C:\Python27\lib\site-packages\deepwalk-1.0.3-py2.7.egg\deepwalk\__main__.py", line 162, in main
    process(args)
  File "C:\Python27\lib\site-packages\deepwalk-1.0.3-py2.7.egg\deepwalk\__main__.py", line 83, in process
    num_workers=args.workers)
  File "C:\Python27\lib\site-packages\deepwalk-1.0.3-py2.7.egg\deepwalk\walks.py", line 85, in write_walks_to_disk
    for file_ in executor.map(_write_walks_to_disk, args_list):
  File "C:\Python27\lib\site-packages\concurrent\futures\_base.py", line 641, in result_iterator
    yield fs.pop().result()
  File "C:\Python27\lib\site-packages\concurrent\futures\_base.py", line 462, in result
    return self.__get_result()
  File "C:\Python27\lib\site-packages\concurrent\futures\_base.py", line 414, in __get_result
    raise exception_type, self._exception, self._traceback
AttributeError: 'NoneType' object has no attribute 'nodes'

But I found something odd about this issue. When i write the code with no options like below:

deepwalk --format mat --input example_graphs/blogcatalog.mat --output example_graphs/blogcatalog.embeddings

I get the below output and I think it is successfully completes:

Number of nodes: 10312
Number of walks: 103120
Data size (walks*length): 4124800
Walking...
Training...

I cannot solve the problem with upgrading packages.

My installed list of packages with versions maybe useful with deepwalk:

Cython                   0.29.16
deepwalk                 1.0.3
future                   0.18.2
futures                  3.3.0
gensim                   3.8.1
networkx                 2.2
pip                      20.0.2
scipy                    1.2.3
six                      1.14.0

Could you please help me about this issue?

xiongshuai520 commented 4 years ago

in walks.py from concurrent.futures import ThreadPoolExecutor as ProcessPoolExecutor problem solved! XD

YES,it works,help other guys can see it

tomatowithpotato commented 3 years ago

in walks.py

from concurrent.futures import ThreadPoolExecutor as ProcessPoolExecutor

problem solved! XD

good guy! 好家伙,你咋那么优秀!