libcity.model.trajectory_loc_prediction.ATSTLSTM

class libcity.model.trajectory_loc_prediction.ATSTLSTM.ATSTLSTM(config, data_feature)[source]

Bases: libcity.model.abstract_model.AbstractModel

ATST_LSTM 轨迹下一跳预测模型.

calculate_loss(batch)[source]

计算模型损失(不包含正则项) :param batch: 输入 :type batch: libcity.data.batch

Returns

shape () 损失

Return type

(torch.tensor.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]
Parameters

batch (Batch) – a batch of input

Returns

predict result of this batch

Return type

torch.tensor

training: bool
class libcity.model.trajectory_loc_prediction.ATSTLSTM.Attn(hidden_size)[source]

Bases: torch.nn.modules.module.Module

Attention 注意力机制模块, 对 LSTM 中间层输出做加权平均.

forward(x)[source]

前向传播. :param x: shape (batch, seq_len, hidden_size) 中间层输出序列 :type x: torch.tensor.Tensor

Returns

shape (batch, size)

Return type

(torch.tensor.Tensor)

training: bool