panzheyi / ST-MetaNet

The codes and data of paper "Urban Traffic Prediction from Spatio-Temporal Data Using Deep Meta Learning"
MIT License
194 stars 73 forks source link

AttributeError: 'NDArray' object has no attribute 'device' #17

Open outside-BUPT opened 1 year ago

outside-BUPT commented 1 year ago

Hi, thank you for sharing your code! When I run the cmd line: python train.py --file model_setting/st-metanet.yaml --gpus 0 --epochs 200 The Traceback message likes:

/home/ypy/rec_sys/env_sb/lib/python3.6/site-packages/dgl/heterograph.py:72: DGLWarning: Recommend creating graphs by dgl.graph(data) instead of dgl.DGLGraph(data). dgl_warning('Recommend creating graphs by dgl.graph(data)' Traceback (most recent call last): File "train.py", line 172, in main(args) File "train.py", line 150, in main metrics = [MAE(scaler), RMSE(scaler), IndexMAE(scaler, [0,1,2]), IndexRMSE(scaler, [0,1,2])], File "train.py", line 72, in fit self.process_data(epoch, train, metrics) File "train.py", line 53, in process_data outputs = [self.net(x, is_training) for x in zip(inputs)] File "train.py", line 53, in outputs = [self.net(x, is_training) for x in zip(inputs)] File "/home/ypy/rec_sys/env_sb/lib/python3.6/site-packages/mxnet/gluon/block.py", line 540, in call out = self.forward(args) File "/home/ypy/rec_sys/ST-MetaNet/traffic-prediction/src/model/seq2seq.py", line 233, in forward states = self.encoder(feature, data) File "/home/ypy/rec_sys/env_sb/lib/python3.6/site-packages/mxnet/gluon/block.py", line 540, in call out = self.forward(args) File "/home/ypy/rec_sys/ST-MetaNet/traffic-prediction/src/model/seq2seq.py", line 52, in forward _data = _data + g(data, feature) File "/home/ypy/rec_sys/env_sb/lib/python3.6/site-packages/mxnet/gluon/block.py", line 540, in call out = self.forward(*args) File "/home/ypy/rec_sys/ST-MetaNet/traffic-prediction/src/model/graph.py", line 70, in forward g = self.get_graph_on_ctx(state.context) File "/home/ypy/rec_sys/ST-MetaNet/traffic-prediction/src/model/graph.py", line 66, in get_graph_on_ctx self.build_graph_on_ctx(ctx) File "/home/ypy/rec_sys/ST-MetaNet/traffic-prediction/src/model/graph.py", line 60, in build_graph_on_ctx g.edata['dist'] = self.dist.as_in_context(ctx) File "/home/ypy/rec_sys/env_sb/lib/python3.6/site-packages/dgl/view.py", line 227, in setitem self._graph._set_e_repr(self._etid, self._edges, {key: val}) File "/home/ypy/rec_sys/env_sb/lib/python3.6/site-packages/dgl/heterograph.py", line 4135, in _set_e_repr if F.context(val) != self.device: File "/home/ypy/rec_sys/env_sb/lib/python3.6/site-packages/dgl/backend/pytorch/tensor.py", line 99, in context return input.device AttributeError: 'NDArray' object has no attribute 'device'

Could you please help me fix this~ Waiting for your reply. Thanks a lot~