Skip to content

Code of testDynTriad has errors #31

@songzeceng

Description

@songzeceng

First it is a remarkable paper and lib for me, but I meet some trouble when testing the code.
Here is the code pasted from the README.md

embedding = dynamicTriad(niters=20,
                         starttime=0,
                         datafile=datafile,
                         batchsize=1000,
                         nsteps=length,
                         embdim=dim_emb,
                         stepsize=1,
                         stepstride=1,
                         outdir=outdir,
                         cachefn='/tmp/' + testDataType,
                         lr=0.1,
                         beta=[0.1, 0.1],
                         negdup=1,
                         datasetmod='core.dataset.adjlist',
                         trainmod='dynamicgem.dynamictriad.core.algorithm.dynamic_triad',
                         pretrain_size=length,
                         sampling_args={},
                         validation='link_reconstruction',
                         datatype=testDataType,
                         scale=1,
                         classifier='lr',
                         debug=False,
                         test='link_predict',
                         repeat=1,
                         resultdir=outdir,
                         testDataType=testDataType,
                         clname='lr',
                         node_num=node_num)
t1 = time()
embedding.learn_embedding()
print(embedding.method_name + ':\n\tTraining time: %f' % (time() - t1))
embedding.get_embedding()
embedding.plotresults(dynamic_sbm_series)

1、Constructor of dynamicTriad has error: argument 'd' not defined

File "/root/PycharmProjects/Textset/DynamicGEM_test.py", line 216, in <module>
    node_num=node_num)
TypeError: __init__() missing 1 required positional argument: 'd'

2、When I removed the codes related with 'd' argument in the constructor of dynamicTriad,another error occured

  ....
  File "/usr/local/lib/python3.6/site-packages/dynamicgem/dynamictriad/core/mygraph_utils.py", line 90, in load_adjlist
    g = mygraph.Graph(node_type, weight_type)
  File "/usr/lib64/python3.6/ctypes/__init__.py", line 356, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib64/python3.6/ctypes/__init__.py", line 361, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /...../DynamicGEM-master/dynamicgem/dynamictriad/core/mygraph-build/mygraph.so: undefined symbol: Graph

It is abvious that mygraph has not attribute Graph when the code mygrah.Graph() is performed.
Here is code related:(dynamicgem\dynamictriad\core\mygraph_utils.py)

def load_adjlist(fn, node_type='string', weight_type='float'):
    """
    loads only undirected graph, if multiple instances of the same edge is detected,
    their weights are summed up
    :param fn:
    :param node_type:
    :param weight_type:
    :return:
    """
    py_node_type = type2python(node_type)
    py_weight_type = type2python(weight_type)

    edgeset = set()  # check if the graph is undirected
    g = mygraph.Graph(node_type, weight_type)
    for line in open(fn, 'r'):
        fields = line.split()
        ......

I also changed the import way of mygrah in this file:

import ctypes
dll_path_ = "/..../DynamicGEM-master/dynamicgem/dynamictriad/core/mygraph-build/mygraph.so"
mygraph = ctypes.cdll.LoadLibrary(dll_path_)

Because the origin way in my CentOS7 is wrong for mygraph is not found as/in a python file

import dynamicgem.dynamictriad.core.mygraph as mygraph

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions