libcity.model.trajectory_loc_prediction.DeepMove

class libcity.model.trajectory_loc_prediction.DeepMove.Attn(method, hidden_size, device)[源代码]

基类:torch.nn.modules.module.Module

Attention Module. Heavily borrowed from Practical Pytorch https://github.com/spro/practical-pytorch/tree/master/seq2seq-translation

forward(out_state, history)[源代码]

[summary]

参数
  • out_state (tensor) – batch_size * state_len * hidden_size

  • history (tensor) – batch_size * history_len * hiddden_size

返回

(batch_size, state_len, history_len)

返回类型

[tensor]

training: bool
class libcity.model.trajectory_loc_prediction.DeepMove.DeepMove(config, data_feature)[源代码]

基类:libcity.model.abstract_model.AbstractModel

rnn model with long-term history attention

calculate_loss(batch)[源代码]
参数

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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

init_weights()[源代码]

Here we reproduce Keras default initialization weights for consistency with Keras version

predict(batch)[源代码]
参数

batch (Batch) – a batch of input

返回

predict result of this batch

返回类型

torch.tensor

training: bool