libcity.model.traffic_od_prediction.CSTN¶
-
class
libcity.model.traffic_od_prediction.CSTN.CNN(height, width, n_layers)[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(x)[源代码]¶ 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_od_prediction.CSTN.CSTN(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
Moduleinstance 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_od_prediction.CSTN.ConvLSTM(input_dim, hidden_dim, kernel_size, num_layers, batch_first=False, bias=True, return_all_layers=False)[源代码]¶ 基类:
torch.nn.modules.module.Module- 参数
input_dim – Number of channels in input
hidden_dim – Number of hidden channels
kernel_size – Size of kernel in convolutions
num_layers – Number of LSTM layers stacked on each other
batch_first – Whether or not dimension 0 is the batch or not
bias – Bias or no bias in Convolution
return_all_layers – Return the list of computations for all layers
Note – Will do same padding.
- Input:
A tensor of size B, T, C, H, W or T, B, C, H, W
- Output:
- A tuple of two lists of length num_layers (or length 1 if return_all_layers is False).
0 - layer_output_list is the list of lists of length T of each output 1 - last_state_list is the list of last states
each element of the list is a tuple (h, c) for hidden state and memory
示例
>> x = torch.rand((32, 10, 64, 128, 128)) >> convlstm = ConvLSTM(64, 16, 3, 1, True, True, False) >> _, last_states = convlstm(x) >> h = last_states[0][0] # 0 for layer index, 0 for h index
-
forward(input_tensor, hidden_state=None)[源代码]¶ 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_od_prediction.CSTN.ConvLSTMCell(input_dim, hidden_dim, kernel_size, bias)[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(input_tensor, cur_state)[源代码]¶ 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_od_prediction.CSTN.GCC[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(x: torch.Tensor)[源代码]¶ 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_od_prediction.CSTN.LSC(height, width, n_layers)[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(x)[源代码]¶ 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_od_prediction.CSTN.MLP[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(x)[源代码]¶ 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_od_prediction.CSTN.TEC(c_lt)[源代码]¶ 基类:
torch.nn.modules.module.Module-
forward(x)[源代码]¶ 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¶
-