libcity.model.traffic_flow_prediction.DGCN

class libcity.model.traffic_flow_prediction.DGCN.DGCN(config, data_feature)[源代码]

基类:libcity.model.abstract_traffic_state_model.AbstractTrafficStateModel

calculate_loss(batch)[源代码]

输入一个batch的数据,返回训练过程的loss,也就是需要定义一个loss函数

参数

batch (Batch) – a batch of input

返回

return training loss

返回类型

torch.tensor

forward(batch)[源代码]

Defines the computation performed at every call.

Should be overridden by all subclasses.

注解

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

predict(batch)[源代码]

输入一个batch的数据,返回对应的预测值,一般应该是**多步预测**的结果,一般会调用nn.Moudle的forward()方法

参数

batch (Batch) – a batch of input

返回

predict result of this batch

返回类型

torch.tensor

training: bool
class libcity.model.traffic_flow_prediction.DGCN.SATT_2(c_in, num_nodes)[源代码]

基类:torch.nn.modules.module.Module

forward(seq)[源代码]

Defines the computation performed at every call.

Should be overridden by all subclasses.

注解

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class libcity.model.traffic_flow_prediction.DGCN.SATT_3(c_in, num_nodes)[源代码]

基类:torch.nn.modules.module.Module

forward(seq)[源代码]

Defines the computation performed at every call.

Should be overridden by all subclasses.

注解

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class libcity.model.traffic_flow_prediction.DGCN.ST_BLOCK_2(c_in, c_out, num_nodes, tem_size, K, Kt, device)[源代码]

基类:torch.nn.modules.module.Module

forward(x, supports)[源代码]

Defines the computation performed at every call.

Should be overridden by all subclasses.

注解

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class libcity.model.traffic_flow_prediction.DGCN.TATT_1(c_in, num_nodes, tem_size, device)[源代码]

基类:torch.nn.modules.module.Module

forward(seq)[源代码]

Defines the computation performed at every call.

Should be overridden by all subclasses.

注解

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class libcity.model.traffic_flow_prediction.DGCN.T_cheby_conv_ds(c_in, c_out, K, Kt, device)[源代码]

基类:torch.nn.modules.module.Module

x : [batch_size, feat_in, num_node ,tem_size] - input of all time step nSample : number of samples = batch_size nNode : number of node in graph tem_size: length of temporal feature c_in : number of input feature c_out : number of output feature adj : laplacian K : size of kernel(number of cheby coefficients) W : cheby_conv weight [K * feat_in, feat_out]

forward(x, adj)[源代码]

Defines the computation performed at every call.

Should be overridden by all subclasses.

注解

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
libcity.model.traffic_flow_prediction.DGCN.cheb_polynomial(l_tilde, k)[源代码]

compute a list of chebyshev polynomials from T_0 to T_{K-1}

参数
  • l_tilde (np.ndarray) – scaled Laplacian, shape (N, N)

  • k (int) – the maximum order of chebyshev polynomials

返回

cheb_polynomials, length: K, from T_0 to T_{K-1}

返回类型

list(np.ndarray)

libcity.model.traffic_flow_prediction.DGCN.scaled_laplacian(weight)[源代码]

compute ilde{L} (scaled laplacian matrix)

参数

weight (np.ndarray) – shape is (N, N), N is the num of vertices

返回

shape (N, N)

返回类型

np.ndarray