System not Loading the graph files.
pradeeptewary opened this issue · 5 comments
Following error occurs, after applying the subgraph2vec technique on my dataset. I also have maintained the specific versions of the python packages, as mentioned.
No handlers could be found for logger "root"
INFO:root:Loaded 59 graph file names form /home/ksec/AMDS/tmp1/cumul
ERROR:root:unable to load graph from file: /home/ksec/AMDS/tmp1/cumul/00001AC7364E668F1DDC9906887EDF0C8F7230830B864DB6179075AC9C0A6892.gexf
ERROR:root:unable to load graph from file: /home/ksec/AMDS/tmp1/cumul/000014F7037586315DE348D21337B90B83A1C887E247DA8E4CC043702E36DFBA.gexf
ERROR:root:unable to load graph from file: /home/ksec/AMDS/tmp1/cumul/00041EC3C57ED823C14129F60DC5B0BCDB6175EF286F85DD25B5BAA317B0EB38.gexf
......
Does it happen for every file in your dataset?
Could you please check if the .gexf files are malformed?
Please load them from ipython/notebook and check.
Yes. It happens for every file.
I am attaching one of the .gexf file. Please see, if it is malformed?
00C6634CDBE2FAF167D5F66EEDE6F2A313FF23471B26A09B202290CF9C11525B.gexf.txt
Please look into the error, which says the vocabulary size is 1, which is not right.
ERROR:root:unable to load graph from file: /home/ksec/AMDS/tmp1/cumul/00FBCD046D40EA127F43EF14626670CBD8FCA00A69CBCCC538A044500B271B80.gexf
INFO:root:Dumped subgraph2vec sentences for all 58 graphs in /home/ksec/AMDS/tmp1/cumul in 0.0 sec
INFO:root:Initializing SKIPGRAM...
INFO:root:vocabulary size: 1
INFO:root:number of documents: 0
INFO:root:number of words to be trained: 2
I tensorflow/core/common_runtime/direct_session.cc:255] Device mapping:
Device mapping: no known devices.
.............................
.............................
Traceback (most recent call last):
File "/home/ksec/PycharmProjects/AMDS/buildModel/main.py", line 107, in
main(args)
File "/home/ksec/PycharmProjects/AMDS/buildModel/main.py", line 50, in main
embedding_fname = train_skipgram(corpus_dir, wl_extn, learning_rate, embedding_size, num_negsample, epochs, batch_size, output_dir,valid_size)
File "/home/ksec/PycharmProjects/AMDS/buildModel/train_utils.py", line 52, in train_skipgram
valid_dataset=valid_examples,
File "/home/ksec/PycharmProjects/AMDS/buildModel/skipgram.py", line 89, in train
batch_data, batch_labels = corpus.generate_batch_from_file(batch_size)# get (target,context) wordid tuples
File "/home/ksec/PycharmProjects/AMDS/buildModel/data_utils.py", line 91, in generate_batch_from_file
doc_name = self.doc_list[self.doc_shuffle[self.graph_index]]
IndexError: list index out of range
is this issue solved? this error also happens when I ran the code.
When you see the gexf file, you can find some of the file does not have the "Label"(index "0") attribute. so yon can change your code like this (I change it to py3, you also can use py2, I insert the -> "if label_field_name in d:")
def read_from_json_gexf(fname=None,label_field_name='Label',conv_undir = False):
'''
Load the graph files (.gexf or .json only supported)
:param fname: graph file name
:param label_field_name: filed denoting the node label
:param conv_undir: convert to undirected graph or not
:return: graph in networkx format
'''
if not fname:
logging.error('no valid path or file name')
return None
else:
try:
try:
with open(fname, 'rb') as File:
org_dep_g = json_graph.node_link_graph(json.load(File))
except:
org_dep_g = nx.read_gexf(fname)
g = nx.DiGraph()
for n, d in org_dep_g.nodes(data=True):
if label_field_name in d:
g.add_node(n, label='-'.join(d[label_field_name].split('\n')) )
g.add_edges_from(org_dep_g.edges())
except Exception as e:
print(org_dep_g.nodes(data=True))
logging.error("unable to load graph from file: {}".format(fname))
# return 0
logging.debug('loaded {} a graph with {} nodes and {} egdes'.format(fname, g.number_of_nodes(),g.number_of_edges()))
if conv_undir:
g = nx.Graph (g)
logging.debug('converted {} as undirected graph'.format (g))
return g