GithubHelp home page GithubHelp logo

t-gcn's Introduction

Overview

This repository includes our works on Graph representation learning and its application on Traffic Flow Prediction.

The ideas behind our works can be abstracted and demonstrated in the following big picture.

All works can be deduced, inspired and created from this picture.

The congruent relationships between Our works included in this repository and the big picture are listed in the following:

The file structure is listed as follows:

1 T-GCN is the source codes for the paper named “T-GCN: A Temporal Graph Convolutional Network for Traffic Prediction” published in IEEE Transactions on Intelligent Transportation Systems (T-ITS) which forged the T-GCN model the spatial and temporal dependence simultaneously.

2 A3T-GCN is the source codes for the paper named “A3T-GCN: Attention Temporal Graph Convolutional Network for Traffic Forecasting” published at ISPRS International Journal of Geo-Information which strengthen the T-GCN model model with attention structure.

3 AST-GCN is the source codes for the paper named “AST-GCN: Attribute-Augmented Spatiotemporal Graph Convolutional Network for Traffic Forecasting” published in IEEE Access which strengthen the T-GCN model model with attribute information.

4 KST-GCN is the source codes for the paper named “KST-GCN: A Knowledge-Driven Spatial-Temporal Graph Convolutional Network for Traffic Forecasting” published in IEEE Transactions on Intelligent Transportation Systems (T-ITS) which which strengthen the T-GCN model model with knowledge graph.

5 CGCN is the source code for the paper named “Curvature graph neural network” published at Information Sciences which used Ricci curvature information to model pivotal nodes. STCGNN is the source code for the paper named "Ollivier–Ricci Curvature Based Spatio-Temporal Graph Neural Networks for Traffic Flow Forecasting" which is an extension of CGCN in the field of traffic forecasting.

6 STGC-GNNs is the source codes for the paper named "STGC-GNNs: A GNN-based traffic prediction framework with a spatial-temporal Granger causality graph" published in Physica A: Statistical Mechanics and its Applications.

7 iGCL is the source codes for the paper named "Augmentation-Free Graph Contrastive Learning of Invariant-Discriminative Representations" published in IEEE Transactions on Neural Networks and Learning Systems.

  1. High-Order Topology-Enhanced Graph Convolutional Networks (HoT-GCN) for Dynamic Graphs.

  2. Alleviating neighbor bias: augmenting graph self-supervise learning with structural equivalent positive samples.

  3. LSTTN: A Long-Short Term Transformer-based Spatiotemporal Neural Network for Traffic Flow Forecasting published in Knowlege-based System.

  4. CAT: A Causally Graph Attention Network for Trimming Heterophilic Graph published in Information Science.

12 Baseline includes methods such as (1) History Average model (HA) (2) Autoregressive Integrated Moving Average model (ARIMA) (3) Support Vector Regression model (SVR) (4) Graph Convolutional Network model (GCN) (5) Gated Recurrent Unit model (GRU)

1. T-GCN: A Temporal Graph Convolutional Network for Traffic Prediction

Accurate and real-time traffic forecasting plays an important role in the Intelligent Traffic System and is of great significance for urban traffic planning, traffic management, and traffic control. However, traffic forecasting has always been considered an open scientific issue, owing to the constraints of urban road network topological structure and the law of dynamic change with time, namely, spatial dependence and temporal dependence. To capture the spatial and temporal dependence simultaneously, we propose a novel neural network-based traffic forecasting method, the temporal graph convolutional network (T-GCN) model, which is in combination with the graph convolutional network (GCN) and gated recurrent unit (GRU). Specifically, the GCN is used to learn complex topological structures to capture spatial dependence and the gated recurrent unit is used to learn dynamic changes of traffic data to capture temporal dependence. Then, the T-GCN model is employed to traffic forecasting based on the urban road network. Experiments demonstrate that our T-GCN model can obtain the spatio-temporal correlation from traffic data and the predictions outperform state-of-art baselines on real-world traffic datasets.

The manuscript can be visited at https://ieeexplore.ieee.org/document/8809901 or https://arxiv.org/abs/1811.05320

The code

2. A3T-GCN: Attention Temporal Graph Convolutional Network for Traffic Forecasting

Accurate real-time traffic forecasting is a core technological problem against the implementation of the intelligent transportation system. However, it remains challenging considering the complex spatial and temporal dependencies among traffic flows. In the spatial dimension, due to the connectivity of the road network, the traffic flows between linked roads are closely related. In terms of the temporal factor, although there exists a tendency among adjacent time points in general, the importance of distant past points is not necessarily smaller than that of recent past points since traffic flows are also affected by external factors. In this study, an attention temporal graph convolutional network (A3T-GCN) traffic forecasting method was proposed to simultaneously capture global temporal dynamics and spatial correlations. The A3T-GCN model learns the short-time trend in time series by using the gated recurrent units and learns the spatial dependence based on the topology of the road network through the graph convolutional network. Moreover, the attention mechanism was introduced to adjust the importance of different time points and assemble global temporal information to improve prediction accuracy. Experimental results in real-world datasets demonstrate the effectiveness and robustness of proposed A3T-GCN.

The manuscript can be visited at https://www.mdpi.com/2220-9964/10/7/485/html or arxiv https://arxiv.org/abs/2006.11583.

The code

3. AST-GCN: Attribute-Augmented Spatiotemporal Graph Convolutional Network for Traffic Forecasting

Traffic forecasting is a fundamental and challenging task in the field of intelligent transportation. Accurate forecasting not only depends on the historical traffic flow information but also needs to consider the influence of a variety of external factors, such as weather conditions and surrounding POI distribution. Recently, spatiotemporal models integrating graph convolutional networks and recurrent neural networks have become traffic forecasting research hotspots and have made significant progress. However, few works integrate external factors. Therefore, based on the assumption that introducing external factors can enhance the spatiotemporal accuracy in predicting traffic and improving interpretability, we propose an attribute-augmented spatiotemporal graph convolutional network (AST-GCN). We model the external factors as dynamic attributes and static attributes and design an attribute-augmented unit to encode and integrate those factors into the spatiotemporal graph convolution model. Experiments on real datasets show the effectiveness of considering external information on traffic speed forecasting tasks when compared with traditional traffic prediction methods. Moreover, under different attribute-augmented schemes and prediction horizon settings, the forecasting accuracy of the AST-GCN is higher than that of the baselines.

The manuscript can be visited at https://ieeexplore.ieee.org/document/9363197 or https://arxiv.org/abs/2011.11004.

The code

4. KST-GCN: A Knowledge-Driven Spatial-Temporal Graph Convolutional Network for Traffic Forecasting

While considering the spatial and temporal features of traffic, capturing the impacts of various external factors on travel is an essential step towards achieving accurate traffic forecasting. However, existing studies seldom consider external factors or neglect the effect of the complex correlations among external factors on traffic. Intuitively, knowledge graphs can naturally describe these correlations. Since knowledge graphs and traffic networks are essentially heterogeneous networks, it is challenging to integrate the information in both networks. On this background, this study presents a knowledge representation-driven traffic forecasting method based on spatial-temporal graph convolutional networks. We first construct a knowledge graph for traffic forecasting and derive knowledge representations by a knowledge representation learning method named KR-EAR. Then, we propose the Knowledge Fusion Cell (KF-Cell) to combine the knowledge and traffic features as the input of a spatial-temporal graph convolutional backbone network. Experimental results on the real-world dataset show that our strategy enhances the forecasting performances of backbones at various prediction horizons. The ablation and perturbation analysis further verify the effectiveness and robustness of the proposed method. To the best of our knowledge, this is the first study that constructs and utilizes a knowledge graph to facilitate traffic forecasting; it also offers a promising direction to integrate external information and spatial-temporal information for traffic forecasting.

The manuscript can be visited at https://ieeexplore.ieee.org/document/9681326/ or https://arxiv.org/abs/2011.14992.

The code

5. Curvature graph neural network

Graph neural networks (GNNs) have achieved great success in many graph-based tasks. Much work is dedicated to empowering GNNs with adaptive locality ability, which enables the measurement of the importance of neighboring nodes to the target node by a node-specific mechanism. However, the current node-specific mechanisms are deficient in distinguishing the importance of nodes in the topology structure. We believe that the structural importance of neighboring nodes is closely related to their importance in aggregation. In this paper, we introduce discrete graph curvature (the Ricci curvature) to quantify the strength of the structural connection of pairwise nodes. We propose a curvature graph neural network (CGNN), which effectively improves the adaptive locality ability of GNNs by leveraging the structural properties of graph curvature. To improve the adaptability of curvature on various datasets, we explicitly transform curvature into the weights of neighboring nodes by the necessary negative curvature processing module and curvature normalization module. Then, we conduct numerous experiments on various synthetic and real-world datasets. The experimental results on synthetic datasets show that CGNN effectively exploits the topology structure information and that the performance is significantly improved. CGNN outperforms the baselines on 5 dense node classification benchmark datasets. This study provides a deepened understanding of how to utilize advanced topology information and assign the importance of neighboring nodes from the perspective of graph curvature and encourages bridging the gap between graph theory and neural networks. The source code is available at https://github.com/GeoX-Lab/CGNN.

The manuscript can be visited at https://www.sciencedirect.com/science/article/pii/S0020025521012986 or https://arxiv.org/abs/2106.15762.

The extension of CGNN in the filed of traffic prediction is Spatio-temporal Cruvature Graph Neural Network(STCGNN). The manuscript can be visited at https://www.mdpi.com/2073-8994/15/5/995.

The code

6.STGC-GNNs: A GNN-based traffic prediction framework with a spatial-temporal Granger causality graph

It is important to model the spatial dependence of the road network for traffic prediction tasks. The essence of spatial dependence is to accurately describe how traffic information transmission is affected by other nodes in the road network, and the GNN-based traffic prediction model, as a benchmark for traffic prediction, has become the most common method for the ability to model spatial dependence by transmitting traffic information with the message passing mechanism. However, the transmission of traffic information is a global and dynamic process in long-term traffic prediction, which cannot be described by the local and static spatial dependence. In this paper, we proposed a spatial-temporal Granger causality(STGC) to model the global and dynamic spatial dependence, which can capture a stable causal relationship between nodes underlying dynamic traffic flow. The STGC can be detected by a spatial-temporal Granger causality test methods proposed by us. We chose T-GCN, STGCN and Graph Wavenet as bakbones, and the experimental results on three backbone models show that using STGC to model the spatial dependence has better results than the original model for 45-min and 1 h long-term prediction.

The manuscript can be visited at https://www.sciencedirect.com/science/article/abs/pii/S0378437123004685 or https://arxiv.org/abs/2210.16789.

The code

7. Augmentation-Free Graph Contrastive Learning of Invariant-Discriminative Representations

Graph contrastive learning is a promising direction toward alleviating the label dependence, poor generalization and weak robustness of graph neural networks, learning representations with invariance, and discriminability by solving pretasks. The pretasks are mainly built on mutual information estimation, which requires data augmentation to construct positive samples with similar semantics to learn invariant signals and negative samples with dissimilar semantics in order to empower representation discriminability. However, an appropriate data augmentation configuration depends heavily on lots of empirical trials such as choosing the compositions of data augmentation techniques and the corresponding hyperparameter settings. We propose an augmentation-free graph contrastive learning method, invariant-discriminative graph contrastive learning (iGCL), that does not intrinsically require negative samples. iGCL designs the invariant-discriminative loss (ID loss) to learn invariant and discriminative representations. On the one hand, ID loss learns invariant signals by directly minimizing the mean square error between the target samples and positive samples in the representation space. On the other hand, ID loss ensures that the representations are discriminative by an orthonormal constraint forcing the different dimensions of representations to be independent of each other. This prevents representations from collapsing to a point or subspace. Our theoretical analysis explains the effectiveness of ID loss from the perspectives of the redundancy reduction criterion, canonical correlation analysis, and information bottleneck principle. The experimental results demonstrate that iGCL outperforms all baselines on 5 node classification benchmark datasets. iGCL also shows superior performance for different label ratios and is capable of resisting graph attacks, which indicates that iGCL has excellent generalization and robustness.

The manuscript can be visited at arxiv https://arxiv.org/abs/2210.08345 or https://ieeexplore.ieee.org/document/10058898.

The code

8. High-Order Topology-Enhanced Graph Convolutional Networks (HoT-GCN) for Dynamic Graphs

Understanding the evolutionary mechanisms of dynamic graphs is crucial since dynamic is a basic characteristic of real-world networks. The challenges of modeling dynamic graphs are as follows: (1) Real-world dynamics are frequently characterized by group effects, which essentially emerge from high-order interactions involving groups of entities. Therefore, the pairwise interactions revealed by the edges of graphs are insufficient to describe complex systems. (2) The graph data obtained from real systems are often noisy, and the spurious edges can interfere with the stability and efficiency of models. To address these issues, we propose a high-order topology-enhanced graph convolutional network for modeling dynamic graphs. The rationale behind it is that the symmetric substructure in a graph, called the maximal clique, can reflect group impacts from high-order interactions on the one hand, while not being readily disturbed by spurious links on the other hand. Then, we utilize two independent branches to model the distinct influence mechanisms of the two effects. Learnable parameters are used to tune the relative importance of the two effects during the process. We conduct link predictions on real-world datasets, including one social network and two citation networks. Results show that the average improvements of the high-order enhanced methods are 68%, 15%, and 280% over the corresponding backbones across datasets. The ablation study and perturbation analysis validate the effectiveness and robustness of the proposed method. Our research reveals that high-order structures provide new perspectives for studying the dynamics of graphs and highlight the necessity of employing higher-order topologies in the future.

The manuscript can be visited at https://www.mdpi.com/2073-8994/14/10/2218.

The code

9. Alleviating neighbor bias: augmenting graph self-supervise learning with structural equivalent positive samples

In recent years, using a self-supervised learning framework to learn the general characteristics of graphs has been considered a promising paradigm for graph representation learning. The core of self-supervised learning strategies for graph neural networks lies in constructing suitable positive sample selection strategies. However, existing GNNs typically aggregate information from neighboring nodes to update node representations, leading to an over-reliance on neighboring positive samples, i.e., homophilous samples; while ignoring long-range positive samples, i.e., positive samples that are far apart on the graph but structurally equivalent samples, a problem we call "neighbor bias." This neighbor bias can reduce the generalization performance of GNNs. In this paper, we argue that the generalization properties of GNNs should be determined by combining homogeneous samples and structurally equivalent samples, which we call the "GC combination hypothesis." Therefore, we propose a topological signal-driven self-supervised method. It uses a topological information-guided structural equivalence sampling strategy. First, we extract multiscale topological features using persistent homology. Then we compute the structural equivalence of node pairs based on their topological features. In particular, we design a topological loss function to pull in non-neighboring node pairs with high structural equivalence in the representation space to alleviate neighbor bias. Finally, we use the joint training mechanism to adjust the effect of structural equivalence on the model to fit datasets with different characteristics. We conducted experiments on the node classification task across seven graph datasets. The results show that the model performance can be effectively improved using a strategy of topological signal enhancement.

The manuscript can be visited at arxiv https://arxiv.org/abs/2212.04365.

The code

10. LSTTN: A Long-Short Term Transformer-based Spatiotemporal Neural Network for Traffic Flow Forecasting

Accurate traffic forecasting is a fundamental problem in intelligent transportation systems and learning long-range traffic representations with key information through spatiotemporal graph neural networks (STGNNs) is a basic assumption of current traffic flow prediction models. However, due to structural limitations, existing STGNNs can only utilize short-range traffic flow data; therefore, the models cannot adequately learn the complex trends and periodic features in traffic flow. Besides, it is challenging to extract the key temporal information from the long historical traffic series and obtain a compact representation. To solve the above problems, we propose a novel LSTTN (Long-Short Term Transformer-based Network) framework comprehensively considering the long- and short-term features in historical traffic flow. First, we employ a masked subseries Transformer to infer the content of masked subseries from a small portion of unmasked subseries and their temporal context in a pretraining manner, forcing the model to efficiently learn compressed and contextual subseries temporal representations from long historical series. Then, based on the learned representations, long-term trend is extracted by using stacked 1D dilated convolution layers, and periodic features are extracted by dynamic graph convolution layers. For the difficulties in making time-step level predictions, LSTTN adopts a short-term trend extractor to learn fine-grained short-term temporal features. Finally, LSTTN fuses the long-term trend, periodic features and short-term features to obtain the prediction results. Experiments on four real-world datasets show that in 60-minute-ahead long-term forecasting, the LSTTN model achieves a minimum improvement of 5.63% and a maximum improvement of 16.78% over baseline models.

The manuscript can be visited at arXiv or sciencedirect

The code

11. CAT: A Causally Graph Attention Network for Trimming Heterophilic Graph

The local attention-guided message passing mechanism (LAMP) adopted in graph attention networks (GATs) can adaptively learn the importance of neighboring nodes and perform local aggregation better, thus demonstrating a stronger discrimination ability. However, existing GATs suffer from significant discrimination ability degradations in heterophilic graphs. The reason is that a high proportion of dissimilar neighbors can weaken the self-attention of the central node, resulting in the central node deviating from its similar nodes in the representation space. This type of influence caused by neighboring nodes is referred to as Distraction Effect (DE) in this paper. To estimate and weaken the DE induced by neighboring nodes, we propose a Causal graph Attention network for Trimming heterophilic graphs (CAT). To estimate the DE, since DE is generated through two paths, we adopt the total effect as the metric for estimating DE; To weaken the DE, we identify the neighbors with the highest DE (we call them Distraction Neighbors) and remove them. We adopt three representative GATs as the base model within the proposed CAT framework and conduct experiments on seven heterophilic datasets of three different sizes. Comparative experiments show that CAT can improve the node classification accuracies of all base GAT models. Ablation experiments and visualization further validate the enhanced discrimination ability of CATs. In addition, CAT is a plug-and-play framework and can be introduced to any LAMP-driven GAT because it learns a trimmed graph in the attention-learning stage, instead of modifying the model architecture or globally searching for new neighbors.

The manuscript can be visited at arXiv or sciencedirect

The code.

t-gcn's People

Contributors

amandalulu1998 avatar geox-lab avatar lehaifeng avatar martinwhl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

t-gcn's Issues

performance is not good

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.

Details on evlaution

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

Use TGCN for dynamic graphs

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?

details about experiments

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]?

Errors on ops

I found error in the code tgcn.py

_ops.RegisterShape("GRUBlockCell")(None)
AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'RegisterShape'

Thank you.

How to deal with time deviation?

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.

关于遇到的一些问题

你好,我仔细阅读了这篇论文(我就不用英文了)
主要想请教两个问题,

  1. trainX, trainY, testX, testY = [], [], [], []
    for i in range(len(train_data) - seq_len - pre_len):
    a = train_data[i: i + seq_len + pre_len]
    trainX.append(a[0 : seq_len])
    trainY.append(a[seq_len : seq_len + pre_len])
    for i in range(len(test_data) - seq_len -pre_len):
    b = test_data[i: i + seq_len + pre_len]
    testX.append(b[0 : seq_len])
    testY.append(b[seq_len : seq_len + pre_len])
    第一个是这段代码中的实际意义我不是很清楚,我只能发现可以解决数组越界这一个问题,所以想请教一下代码的实际含义。
    2.第二个是论文中的两个数据集都是预测了之后15min,30min,45min以及60min的数据,但两个数据集的时间间隔是不一样的,Los-loop数据集的时间间隔是5min。以15min为例,这样是可以预测到后3个时间间隔的速度么?

Topological tolerance

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.

关于sz_speed数据集的问题

你好,乐先生!请教你一个问题,你在论文中提到的关于sz_speed数据集中,说到“每行代表一条路;每一列是不同时间段道路上的交通速度。我们每15分钟汇总一次每条路上的交通速度“,但我在深圳数据集中看到的是2977行、156列,这是你论文中提到的不符,能否告知一下这是为什么?

class tgcnCell

Could someone please give some explanation about tgcn.py.

How to run GCN model?

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!

Pytorch Version

Hello Haifeng,

thanks for your amazing. Could you also provide the PyTorch version code?

Data source

Hi. I really liked your paper.

  1. Can you provide the link of the online repository from where you took data for your experiments?
  2. https://www.cs.rutgers.edu/~dz220/data.html is this the site for shehnzen data?
  3. where did you get the data for the adjacency matrix data for connectivity among the nodes? Did you do it manually?

Standalone GRU code

@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

tgcn model

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.

about tensorflow.contrib.rnn

there is an error "no module named tensorflow.contrib.rnn" in tf2.0, is there any alternative way to import this?
Thank you!

how to restore pre-trained meta model and pass it's weights and biases to the optimizer?

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'

How do you get the adjacency matrix of sz or los?

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!!!

Why not GAT?

I think u can use attention mechanisms to make spatial and temporal features more prominent.

what is the shape of Xt?

in paper , you say Xt ∈ RN×i is used to represent the speed on each road at time i. I feel confused it.

TCN Pytorch 版本是否还未完善?

您好!
我注意到 TCN 的代码里面最后给出的是 每个units的输出 (batch_size, num_nodes, num_gru_units),作者是否打算截取最后一个unit 的输出, 并变换成 (batch_size, num_nodes, len_for_predict)?

tensorflow 版本

请问下实现这个的tensorflow版本是多少吗,希望能复现下模型训练 。

Can T-GCN deal with multivariate time series features?

Hi,
I would really appreciate it if you can help with the issues:

  1. 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)

  2. Can non-time series feature be added to the model?

  3. 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!

How can i use this code in classfication problem?

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

output about test_result file

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!

您好,关于训练结果可视化的问题。

您好,打扰您一下,我用的是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

tgcn中如何结合gcn和gru

您好:我最近在阅读您发表的T-GCN这篇论文,并学习了您的代码。我是一位初学者,关于代码有几个问题,想请教您。
在代码tgcn中,您是否先用图卷积gcn处理邻接矩阵得到结果,再把这个结果和道路属性特征(即每条道路的时间序列数据)一起作为gru的输入吗?两者是如何结合在一起作为gru的输入?我有一些困惑。
其次,我想了解图卷积gcn处理邻接矩阵得到的输出是什么?
希望您在百忙之中可以回复我的问题,非常感谢!

Flag declaration problem

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.

万分感谢!

您写的代码非常优美,上传的内容也非常完整,我已经复现!让我这个新手学到了很多,非常感谢您。

Some questions on baseline.py

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

  1. how the periods = 5664 could be used as len(data.index) equals to 2016 only.
  2. Why 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.
  3. Which ARIMA model you are using? ARIMA(1,0,0)?

Thanks in advance.

GCN code

hi, thank you for sharing. I've studied your paper and code and have some questions:

  1. 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 ?

  2. 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.

graph convolution process in `tgcn` cell

Hi @lehaifeng,

Once again, thanks for pasting the code here. I got a question on the graph convolution when I read tgcn.py.

T-GCN/tgcn.py

Lines 53 to 62 in 24fc8d8

x_s = tf.concat([inputs, state], axis=2)
input_size = x_s.get_shape()[2].value
## (num_node,input_size,-1)
x0 = tf.transpose(x_s, perm=[1, 2, 0])
x0 = tf.reshape(x0, shape=[self._nodes, -1])
scope = tf.get_variable_scope()
with tf.variable_scope(scope):
for m in self._adj:
x1 = tf.sparse_tensor_dense_matmul(m, x0)

As above, it seems to me that the convolution is

ql_36361ffe3511d210798d4cdb1415a82f_l3

instead of

ql_9830f373b0708043aba2483a7353524e_l3

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.