libcity.model.trajectory_loc_prediction.CARA

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

Bases: libcity.model.abstract_model.AbstractModel

rnn model with long-term history attention

calculate_loss(batch)[source]
Parameters

batch (Batch) – a batch of input

Returns

return training loss

Return type

torch.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.

get_distance(lat1, lng1, lat2, lng2)[source]
get_neg_checkins(vis, x, y)[source]
get_pos_distance(x)[source]
get_pos_distance2(x)[source]
get_time_interval(x)[source]
get_time_interval2(x)[source]
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.CARA.CARA1(output_dim, input_dim, init='glorot_uniform', inner_init='orthogonal', device=None, **kwargs)[source]

Bases: torch.nn.modules.module.Module

add_weight(shape, initializer)[source]
build(input_shape)[source]
forward(x)[source]

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

hard_sigmoid(x)[source]
preprocess_input(x)[source]
step(x, states)[source]

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

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

Bases: torch.nn.modules.module.Module

forward(x)[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.

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