easy_tpp.model.torch_model.torch_intensity_free

Functions

clamp_preserve_gradients(x, min_val, max_val)

Clamp the tensor while preserving gradients in the clamped region.

Classes

IntensityFree(model_config)

Torch implementation of Intensity-Free Learning of Temporal Point Processes, ICLR 2020.

LogNormalMixtureDistribution(locs, ...[, ...])

Mixture of log-normal distributions.

MixtureSameFamily(mixture_distribution, ...)

Mixture (same-family) distribution, redefined log_cdf and log_survival_function.

Normal(loc, scale[, validate_args])

Normal distribution, redefined log_cdf and log_survival_function due to no numerically stable implementation of them is available for normal distribution.

easy_tpp.model.torch_model.torch_intensity_free.clamp_preserve_gradients(x, min_val, max_val)[source]

Clamp the tensor while preserving gradients in the clamped region.

Parameters:
  • x (tensor) – tensor to be clamped.

  • min_val (float) – minimum value.

  • max_val (float) – maximum value.

class easy_tpp.model.torch_model.torch_intensity_free.Normal(loc, scale, validate_args=None)[source]

Normal distribution, redefined log_cdf and log_survival_function due to no numerically stable implementation of them is available for normal distribution.

class easy_tpp.model.torch_model.torch_intensity_free.MixtureSameFamily(mixture_distribution, component_distribution, validate_args=None)[source]

Mixture (same-family) distribution, redefined log_cdf and log_survival_function.

class easy_tpp.model.torch_model.torch_intensity_free.LogNormalMixtureDistribution(locs, log_scales, log_weights, mean_log_inter_time, std_log_inter_time, validate_args=None)[source]

Mixture of log-normal distributions.

Parameters:
  • locs (tensor) – [batch_size, seq_len, num_mix_components].

  • log_scales (tensor) – [batch_size, seq_len, num_mix_components].

  • log_weights (tensor) – [batch_size, seq_len, num_mix_components].

  • mean_log_inter_time (float) – Average log-inter-event-time.

  • std_log_inter_time (float) – Std of log-inter-event-times.

__init__(locs, log_scales, log_weights, mean_log_inter_time, std_log_inter_time, validate_args=None)[source]
class easy_tpp.model.torch_model.torch_intensity_free.IntensityFree(model_config)[source]

Torch implementation of Intensity-Free Learning of Temporal Point Processes, ICLR 2020. https://openreview.net/pdf?id=HygOjhEYDH

reference: https://github.com/shchur/ifl-tpp

__init__(model_config)[source]

Initialize the model

Parameters:

model_config (EasyTPP.ModelConfig) – config of model specs.

forward(time_delta_seqs, type_seqs)[source]

Call the model.

Parameters:
  • time_delta_seqs (tensor) – [batch_size, seq_len], inter-event time seqs.

  • type_seqs (tensor) – [batch_size, seq_len], event type seqs.

Returns:

hidden states, [batch_size, seq_len, hidden_dim], states right before the event happens.

Return type:

list

loglike_loss(batch)[source]

Compute the loglike loss.

Parameters:

batch (list) – batch input.

Returns:

loglikelihood loss and num of events.

Return type:

tuple