lehaifeng / t-gcn Goto Github PK
View Code? Open in Web Editor NEWTemporal Graph Convolutional Network for Urban Traffic Flow Prediction Method
Temporal Graph Convolutional Network for Urban Traffic Flow Prediction Method
Hi , I have read your paper and try to understand the model but I got some problems. i am not quite understand that why the state part (which I thought that is a gru thing) , would also be send into the graph conv function? I am just a rookie on gcn and gru , hope I could get some help, thanks.
I found error in the code tgcn.py
_ops.RegisterShape("GRUBlockCell")(None)
AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'RegisterShape'
Thank you.
Hi,
I would really appreciate it if you can help with the issues:
It seems that GCN_LSTM is a univariate time series forecasting method. Is it possible to use multivariate time series features to build the model? ( I found relevant issue on #21 but failed to find the knowledge graph)
Can non-time series feature be added to the model?
So the architecture comprises of a stack of N1 Graph Convolutional layers followed by N2 LSTM layers, a Dropout layer, and a Dense layer. Am I correct?
Thank you so much for your help!
Could someone please give some explanation about tgcn.py.
Sorry to bother you,I have studied your paper and code in recent days.and i am deeply inspired by your idea,During the study period,two questions occour in my mind.
1,if i want to categorize articles that have references to each other,which part of code do i need to modify?
2,I noticed that the adjency matrix is not only contain 0 and 1,how to understand that?
Looking forward to your reply
你好,我仔细阅读了这篇论文(我就不用英文了)
主要想请教两个问题,
您好!
我注意到 TCN 的代码里面最后给出的是 每个units的输出 (batch_size, num_nodes, num_gru_units),作者是否打算截取最后一个unit 的输出, 并变换成 (batch_size, num_nodes, len_for_predict)?
Wondering if we can apply the graph convolution layer to a directed graph? The Fourier domain may not be well-defined in this case?
In main.py line 30 it should be DEFINE_float instead of DEFINE_integer since you're using 0.8 as the value.
Cheers and tank you for sharing the code.
Hi lehaifeng!
We are going to try a traffic speed prediction based on your T-GCN and we are trying your baselines.py
for our understanding. We are grateful if you would throw more lights on
periods = 5664
could be used as len(data.index)
equals to 2016 only.rmse
of HA
in Table 1
of the paper https://arxiv.org/pdf/1811.05320.pdf appears the same across T = 15, 30, 45, 60
mins.ARIMA
model you are using? ARIMA(1,0,0)
?Thanks in advance.
Hi. I really liked your paper.
Could you please offer the version of tensorflow which you uesd?
作者代码里是只用了一层GCN吗?
there is an error "no module named tensorflow.contrib.rnn" in tf2.0, is there any alternative way to import this?
Thank you!
I want to compare GRU and GCN. Can I expose this part of the code?thank you
请问下实现这个的tensorflow版本是多少吗,希望能复现下模型训练 。
@lehaifeng Could you please upload the standalone GRU code. I have been tuning my network but I am unable to reach the accuracy stated in the paper.
Thanks
Thanks again your meaningful article and code.
I have a question here: We know that the speed of a point depends on the speed of the previous points. For example, a car drive into expressway and pass the point A at time t, and it will effect the point B at time t+Δt. So there is a time deviation Δt between A and B. So after you capture the spatial feature by GCN, will the time deviation impress the effect of LSTM ?Is it necessary to involve attention mechanism like GAT to solve this problem? Looking forward to your opinion.
您写的代码非常优美,上传的内容也非常完整,我已经复现!让我这个新手学到了很多,非常感谢您。
源代码中,seq_len=12,pre_len=3是预测15分钟,如果预测30分钟,pre_len=6,那么seq_len也要变成24吗?
Hello Haifeng,
thanks for your amazing. Could you also provide the PyTorch version code?
In this paper, the next 15,30,45,60min is predicted, this means the prediction length on los-loop is [1,2,3,4], and on Sz-taxi is [3,6,9,12]?
hi mr le
thank u for your contribution of the open source code and data :D
I am doing traffic speed predication of changsha now,but I met a problem when i process the road network data。。。can i ask how do you get the adjacency matrix of sz?thank u very much!!!
Thanks for the code sharing.
I got a similar case with traffic speed on road network as data and I convert the road network to line graph for GCN.
My case got a bit tricky: road network may change; some road may be blocked due to reconstructing.
My question is what will be the tolerance of the GCN model to edge change? I don’t know how to quantify, but it would be great if you share us your experience. Thanks in advance.
Thanks for your work. Would you please give me the link of los-loop dataset that collected in the highway of Los Angeles County ?
您好,打扰您一下,我用的是pytorch版本的代码,第55行代码也修改成为loss = self.loss(predictions, y),在电脑上运行完毕后,正确率一直是在85%左右。
第二个问题是,最终的训练结果可视化,在代码中,是定义了显示图片的函数,但是运行结束后,似乎是没有图片显示出来的
[2021-04-12 09:57:37,792 INFO]val_loss│RMSE│MAE│accuracy│R2│ExplainedVar│train_loss
─────────────────────────────────────────────────────
73.09178161621094│8.549372673034668│6.055265426635742│0.8544564843177795│0.6201916933059692│0.6203931570053101│0.007503977511078119
你好,乐先生!请教你一个问题,你在论文中提到的关于sz_speed数据集中,说到“每行代表一条路;每一列是不同时间段道路上的交通速度。我们每15分钟汇总一次每条路上的交通速度“,但我在深圳数据集中看到的是2977行、156列,这是你论文中提到的不符,能否告知一下这是为什么?
I have a trouble in predicting new values after I trained and evaluated the model. Thank you!
some errors exist during runing
I think u can use attention mechanisms to make spatial and temporal features more prominent.
The output'shape of _gconv function(in gcn.py) is [batch*, self._output_dim, self._num_nodes], but the weights['out']'s shape is [gru_units, pre_len], need to redefine a fully connected layer to generate for GCN?
Thank you very much for uploading your paper's code.
Thank you!
您好:我最近在阅读您发表的T-GCN这篇论文,并学习了您的代码。我是一位初学者,关于代码有几个问题,想请教您。
在代码tgcn中,您是否先用图卷积gcn处理邻接矩阵得到结果,再把这个结果和道路属性特征(即每条道路的时间序列数据)一起作为gru的输入吗?两者是如何结合在一起作为gru的输入?我有一些困惑。
其次,我想了解图卷积gcn处理邻接矩阵得到的输出是什么?
希望您在百忙之中可以回复我的问题,非常感谢!
hi, thank you for sharing. I've studied your paper and code and have some questions:
according your paper, the gcn model is expressed as:
f(X, A) = act(A Relu (AXW0) W1)
but in tgcn.py, it seems like:
f(X, A) = AXW0 + b0
in gcn.py, it looks like:
f(X, A) = act(AXW0)W1 (act is tanh by default)
do I misunderstand it ?
the following code in gcn.py & tgcn.py:
for adj in self._adj:
x1 = tf.sparse_tensor_dense_matmul(adj, x0)
in your implementation, the self._adj is a list that contains only one element, that's OK.
but if it contains more than one element? the loop seems to have no effect, it only uses
the last element.
I run the code, but I can't reach the author's good performance in the paper, the accuracy is lower, and even the r2 and var sometimes is negative.
Hi @lehaifeng,
Once again, thanks for pasting the code here. I got a question on the graph convolution when I read tgcn.py
.
Lines 53 to 62 in 24fc8d8
As above, it seems to me that the convolution is
instead of
similar for r_t
and c_t
, as written in the paper (https://arxiv.org/pdf/1811.05320.pdf). Not sure if I am misunderstood. Mind throwing some lights to me? Thanks in advance.
in paper , you say Xt ∈ RN×i is used to represent the speed on each road at time i. I feel confused it.
Hey Mr.Haifeng
I trained a model on a specific dataset and saved it as a meta, I want to restore the model and use its weights and biases on another dataset the code isn't mine but I'm trying to restore the architecture after it was saved to metafile.
I tried many workarounds and ran into numerous errors I can't post all of them here, is it possible to do transfer learning using this architecture, I can use this architecture on any new dataset, but I can't reuse the trained model variables on another data set.
Should I save operations done in the original graph and then call them in the new code.?
This is the code I'm using to restore weights and biases as well as placeholders.
sess=tf.Session()
saver2 = tf.train.import_meta_graph('TGCNpretrain.model.meta')
saver2.restore(sess, tf.train.latest_checkpoint('./'))
print("model restored")
graph = tf.get_default_graph()
print(tf.compat.v1.trainable_variables())
print("------------------------------------------------------------------------------")
weights ={
'out2':[v for v in tf.trainable_variables() if v.name == "weight_o:0"][0]}
biases ={
'out2':[v for v in tf.trainable_variables() if v.name == "bias_o:0"][0]}
###### placeholders ######
inputs = tf.get_default_graph().get_tensor_by_name('inputs1:0')
labels = tf.get_default_graph().get_tensor_by_name('labels1:0')
y_pred = inputs
###### optimizer ######
Lreg = sum(tf.nn.l2_loss(tf_var) for tf_var in tf.trainable_variables())
label = tf.reshape(labels, [-1,num_nodes])
##loss
loss = tf.reduce_mean(tf.nn.l2_loss(y_pred-label) + Lreg)
##rmse
error = tf.sqrt(tf.reduce_mean(tf.square(y_pred-label)))
optimizer = tf.train.AdamOptimizer(lr).minimize(loss)
I don't know what to pass to the optimizer, loss and error equations, I tried several combinations as shaping error all the time
ValueError: Shapes must be equal rank, but are 2 and 1 From merging shape 4 with other shapes. for 'Rank/packed' (op: 'Pack')
I also run this error very often
raise ValueError(str(e)) ValueError: Duplicate node name in graph: 'weight_o/Adam'
Hi Mr Le
in paper T-GCN, about SZ-taxi dataset, This dataset consists of the taxi trajectory of Shenzhen from Jan. 1 to Jan. 31, 2015 and you aggregated the traffic speed on each road every 15 minutes. 80% of the data is used as the training set and the remaining 20% is used as the test set, that means Jan.27-Jan.31 is the prediction result. However, in test_result(result of prediction ) file, there are 591 rows that does not match Jan.27-Jan.31. In theory, it should be 576 rows. I have the same question on another data set.
I am looking forward to your reply Thank you!
Hi, It would be so nice if you specify how we can use TGC for dynamic graphs with different adjacency matrix and feature matrix in each snapshot?
Hi!
I wondering you trained 4 different T-GCN models to predict 15,30,45, and 60 minutes later.
or you reused the one T-GCN model to predict 4 different scenarios. cuz the T-GCN is based on RNN, if you feedback the output of T-GCN to the input, it can predict any point of future in theory. isn't it?
Thanks,
Jun
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.