libcity.model.trajectory_loc_prediction.CARA

class libcity.model.trajectory_loc_prediction.CARA.CARA(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.

get_distance(lat1, lng1, lat2, lng2)[源代码]
get_neg_checkins(vis, x, y)[源代码]
get_pos_distance(x)[源代码]
get_pos_distance2(x)[源代码]
get_time_interval(x)[源代码]
get_time_interval2(x)[源代码]
predict(batch)[源代码]
参数

batch (Batch) – a batch of input

返回

predict result of this batch

返回类型

torch.tensor

training: bool
class libcity.model.trajectory_loc_prediction.CARA.CARA1(output_dim, input_dim, init='glorot_uniform', inner_init='orthogonal', device=None, **kwargs)[源代码]

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

add_weight(shape, initializer)[源代码]
build(input_shape)[源代码]
forward(x)[源代码]

X : batch * timeLen * dims(有拓展)

hard_sigmoid(x)[源代码]
preprocess_input(x)[源代码]
step(x, states)[源代码]

用于多批次同一时间 states为上一次多批次统一时间数据

training: bool
class libcity.model.trajectory_loc_prediction.CARA.Recommender(num_users, num_items, num_times, latent_dim, maxvenue=5, device=None)[源代码]

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

rank(uid, hist_venues, hist_times, hist_time_gap, hist_distances)[源代码]
training: bool
libcity.model.trajectory_loc_prediction.CARA.bpr_triplet_loss(x)[源代码]
libcity.model.trajectory_loc_prediction.CARA.identity_loss(y_true, y_pred)[源代码]