libcity.model.trajectory_loc_prediction.STAN

class libcity.model.trajectory_loc_prediction.STAN.Attn(max_len, emb_loc, loc_max, device, dropout=0.1)[source]

Bases: torch.nn.modules.module.Module

forward(self_attn, self_delta, traj_len)[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.trajectory_loc_prediction.STAN.Embed(ex, emb_size, loc_max, embed_layers)[source]

Bases: torch.nn.modules.module.Module

forward(traj_loc, mat2, vec, traj_len)[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.trajectory_loc_prediction.STAN.MultiEmbed(ex, emb_size, embed_layers)[source]

Bases: torch.nn.modules.module.Module

forward(traj, mat, traj_len)[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.trajectory_loc_prediction.STAN.STAN(config, data_feature)[source]

Bases: libcity.model.abstract_model.AbstractModel

calculate_loss(batch)[source]
参数说明:

batch (libcity.data.batch): 类 dict 文件,其中包含的键值参见任务说明文件。

返回值:
loss (pytorch.tensor): 可以调用 pytorch 实现的 loss 函数与 batch[‘target’]

目标值进行 loss 计算,并将计算结果返回。如模型有自己独特的 loss 计算方式则自行参考实现。

forward(traj, mat1, vec, traj_len)[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 (libcity.data.batch): 类 dict 文件,其中包含的键值参见任务说明文件。

返回值:
score (pytorch.tensor): 对应张量 shape 应为 batch_size *

loc_size。这里返回的是模型对于输入当前轨迹的下一跳位置的预测值。

training: bool
class libcity.model.trajectory_loc_prediction.STAN.SelfAttn(emb_size, output_size, dropout=0.1)[source]

Bases: torch.nn.modules.module.Module

forward(joint, delta, traj_len)[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