libcity.model.traffic_speed_prediction.GMAN¶
-
class
libcity.model.traffic_speed_prediction.GMAN.
FC
(input_dims, units, activations, bn, bn_decay, device, use_bias=True)[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_speed_prediction.GMAN.
GMAN
(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¶
-
-
class
libcity.model.traffic_speed_prediction.GMAN.
GatedFusion
(D, bn, bn_decay, device)[source]¶ Bases:
torch.nn.modules.module.Module
-
forward
(HS, HT)[source]¶ gated fusion HS: (batch_size, num_step, num_nodes, D) HT: (batch_size, num_step, num_nodes, D) return: (batch_size, num_step, num_nodes, D)
-
training
: bool¶
-
-
class
libcity.model.traffic_speed_prediction.GMAN.
STAttBlock
(K, D, bn, bn_decay, device, mask=True)[source]¶ Bases:
torch.nn.modules.module.Module
-
forward
(x, ste)[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_speed_prediction.GMAN.
STEmbedding
(T, D, bn, bn_decay, add_day_in_week, device)[source]¶ Bases:
torch.nn.modules.module.Module
-
forward
(SE, TE)[source]¶ spatio-temporal embedding SE: (num_nodes, D) TE: (batch_size, input_length+output_length, 7+T or T) retrun: (batch_size, input_length+output_length, num_nodes, D)
-
training
: bool¶
-
-
class
libcity.model.traffic_speed_prediction.GMAN.
SpatialAttention
(K, D, bn, bn_decay, device)[source]¶ Bases:
torch.nn.modules.module.Module
-
forward
(x, ste)[source]¶ spatial attention mechanism x: (batch_size, num_step, num_nodes, D) ste: (batch_size, num_step, num_nodes, D) return: (batch_size, num_step, num_nodes, D)
-
training
: bool¶
-
-
class
libcity.model.traffic_speed_prediction.GMAN.
TemporalAttention
(K, D, bn, bn_decay, device, mask=True)[source]¶ Bases:
torch.nn.modules.module.Module
-
forward
(x, ste)[source]¶ temporal attention mechanism x: (batch_size, num_step, num_nodes, D) ste: (batch_size, num_step, num_nodes, D) return: (batch_size, num_step, num_nodes, D)
-
training
: bool¶
-
-
class
libcity.model.traffic_speed_prediction.GMAN.
TransformAttention
(K, D, bn, bn_decay, device)[source]¶ Bases:
torch.nn.modules.module.Module
-
forward
(x, ste1, ste2)[source]¶ transform attention mechanism x: (batch_size, input_length, num_nodes, D) ste_1: (batch_size, input_length, num_nodes, D) ste_2: (batch_size, output_length, num_nodes, D) return: (batch_size, output_length, num_nodes, D)
-
training
: bool¶
-