libcity.model.traffic_demand_prediction.STG2Seq

class libcity.model.traffic_demand_prediction.STG2Seq.Align(c_in, c_out)[source]

Bases: torch.nn.modules.module.Module

forward(x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

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_demand_prediction.STG2Seq.AttentionC(device, num_nodes, d_out, ext_dim)[source]

Bases: torch.nn.modules.module.Module

forward(query, x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

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_demand_prediction.STG2Seq.AttentionT(device, len_time, num_nodes, d_out, ext_dim)[source]

Bases: torch.nn.modules.module.Module

forward(query, x)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

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_demand_prediction.STG2Seq.ConvST(supports, kt, ks, dim_in, dim_out, device)[source]

Bases: torch.nn.modules.module.Module

forward(x)[source]
Parameters

x – torch.tensor, shape=[B, dim_in, T, num_nodes]

Returns

shape=[B, dim_out, T, num_nodes]

Return type

torch.tensor

graph_conv(inputs, supports, dim_in, dim_out)[source]
Parameters
  • inputs – a tensor of shape [batch, num_nodes, dim_in]

  • supports – [num_nodes, num_nodes*ks], calculate the chebyshev polynomials in advance to save time

  • dim_in

  • dim_out

Returns

shape = [batch, num_nodes, dim_out]

Return type

torch.tensor

training: bool
class libcity.model.traffic_demand_prediction.STG2Seq.STG2Seq(config, data_feature)[source]

Bases: libcity.model.abstract_traffic_state_model.AbstractTrafficStateModel

calculate_loss(batch)[source]

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

Parameters

batch (Batch) – a batch of input

Returns

return training loss

Return type

torch.tensor

forward(batch)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

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)[source]

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

Parameters

batch (Batch) – a batch of input

Returns

predict result of this batch

Return type

torch.tensor

training: bool
libcity.model.traffic_demand_prediction.STG2Seq.cheb_poly(lap, ks)[source]
libcity.model.traffic_demand_prediction.STG2Seq.scaled_laplacian(w)[source]