libcity.model.traffic_demand_prediction.CCRNN¶
-
class
libcity.model.traffic_demand_prediction.CCRNN.CCRNN(config, data_feature)[源代码]¶ 基类:
libcity.model.abstract_traffic_state_model.AbstractTrafficStateModel-
calculate_loss(batch, batches_seen=None)[源代码]¶ 输入一个batch的数据,返回训练过程的loss,也就是需要定义一个loss函数
- 参数
batch (Batch) – a batch of input
- 返回
return training loss
- 返回类型
torch.tensor
-
forward(batch, batches_seen=None)[源代码]¶ dynamic convolutional recurrent neural network :param inputs: [B, input_window, N, input_dim] :param targets: exists for training, tensor, [B, output_window, N, output_dim] :param batch_seen: int, the number of batches the model has seen :return: [B, n_pred, N, output_dim],[]
-
predict(batch, batches_seen=None)[源代码]¶ 输入一个batch的数据,返回对应的预测值,一般应该是**多步预测**的结果,一般会调用nn.Moudle的forward()方法
- 参数
batch (Batch) – a batch of input
- 返回
predict result of this batch
- 返回类型
torch.tensor
-
training: bool¶
-
-
class
libcity.model.traffic_demand_prediction.CCRNN.DCGRUCell(input_size: int, hidden_size: int, num_node: int, n_supports: int, k_hop: int, e_layer: int, n_dim: int)[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(inputs: torch.Tensor, supports: List[torch.Tensor], states) → Tuple[torch.Tensor, torch.Tensor][源代码]¶ - 参数
inputs – Tensor[Batch, Node, Feature]
supports –
:param states:Tensor[Batch, Node, Hidden_size] :return:
-
training: bool¶
-
-
class
libcity.model.traffic_demand_prediction.CCRNN.DCRNNDecoder(output_size: int, hidden_size: int, num_node: int, n_supports: int, k_hop: int, n_layers: int, n_preds: int, e_layer: int, n_dim: int)[源代码]¶ 基类:
torch.nn.modules.container.ModuleList-
forward(supports: List[torch.Tensor], states: torch.Tensor, targets: torch.Tensor = None, teacher_force: bool = 0.5) → torch.Tensor[源代码]¶ - 参数
supports – list of sparse tensors, each of shape [N, N]
states – tensor, [n_layers, B, N, hidden_size]
targets – None or tensor, [B, T, N, output_size]
teacher_force – random to use targets as decoder inputs
- 返回
tensor, [B, T, N, output_size]
-
training: bool¶
-
-
class
libcity.model.traffic_demand_prediction.CCRNN.DCRNNEncoder(input_size: int, hidden_size: int, num_node: int, n_supports: int, k_hop: int, n_layers: int, e_layer: int, n_dim: int)[源代码]¶ 基类:
torch.nn.modules.container.ModuleList-
forward(inputs: torch.Tensor, supports: List[torch.Tensor]) → torch.Tensor[源代码]¶ - 参数
inputs – tensor, [B, T, N, input_size]
supports – list of sparse tensors, each of shape [N, N]
- 返回
tensor, [n_layers, B, N, hidden_size]
-
training: bool¶
-
-
class
libcity.model.traffic_demand_prediction.CCRNN.EvolutionCell(input_dim: int, output_dim: int, num_nodes: int, n_supports: int, max_step: int, layer: int, n_dim: int)[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(inputs, supports: List)[源代码]¶ 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
Moduleinstance 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.CCRNN.GraphConv(input_dim: int, output_dim: int, num_nodes: int, n_supports: int, max_step: int)[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(inputs: torch.Tensor, supports: List[torch.Tensor])[源代码]¶ - 参数
inputs – tensor, [B, N, input_dim]
supports – list of sparse tensors, each of shape [N, N]
- 返回
tensor, [B, N, output_dim]
-
training: bool¶
-
-
class
libcity.model.traffic_demand_prediction.CCRNN.GraphConvMx(input_dim: int, output_dim: int, num_nodes: int, n_supports: int, max_step: int)[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(inputs: torch.Tensor, supports: List[torch.Tensor])[源代码]¶ - 参数
inputs – tensor, [B, N, input_dim]
supports – list of sparse tensors, each of shape [N, N]
- 返回
tensor, [B, N, output_dim]
-
training: bool¶
-
-
libcity.model.traffic_demand_prediction.CCRNN.graph_preprocess(matrix, normalized_category=None)[源代码]¶