uctb / UCTB

An Open Source Spatio-Temporal Prediction Package
MIT License
180 stars 42 forks source link

'my_data_loader' object has no attribute 'AM' #6

Closed Star-live closed 3 years ago

Star-live commented 3 years ago

When I run this file https://github.com/uctb/UCTB/blob/master/QuickStarts/DCRNN.py, the program shows the following error:

Traceback (most recent call last):
  File "/home/zhuhang/.pycharm_helpers/pydev/pydevd.py", line 1434, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/zhuhang/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/zhuhang/WorkSpace/UCTB/DCRNN.py", line 32, in <module>
    diffusion_matrix = data_loader.diffusion_matrix()
  File "/home/zhuhang/WorkSpace/UCTB/DCRNN.py", line 18, in diffusion_matrix
    assert len(self.AM) == 1
AttributeError: 'my_data_loader' object has no attribute 'AM'

I am sure that the UTCB I installed is correct, and the data can be loaded normally, because I can run the following file normally https://github.com/uctb/UCTB/blob/master/QuickStarts/Visualization.py.

Excuse me, how should I modify it so that it can be used normally?

Liyue-Chen commented 3 years ago

Hi~

You may add __init__ function in your own DCRNN class like this:

`class my_data_loader(NodeTrafficLoader):

def __init__(self, **kwargs):

    super(my_data_loader, self).__init__(**kwargs) 

    # generate LM
    graph_obj = GraphGenerator(graph=kwargs['graph'], data_loader=self)
    self.AM = graph_obj.AM
    self.LM = graph_obj.LM

` We just update DCRNN QuickStart and you can follow it.

Thanks for your attention.

Star-live commented 3 years ago

Thank you very much, now I can run it successfully.