S2P2#

Summary#

A continuous-time state-space model that evolves event-conditioned states and maps them to marked intensities.

Intensity and objective#

forward builds the continuous-time state-space history using components from easy_tpp.ssm. _get_intensity passes the evolved states through each layer’s depth_pass and calls IntensityNet on the resulting residual-stream representation:

\[\lambda_k(t)=\operatorname{ScaledSoftplus}_k([W r(t)+b]_k).\]

Here \(r(t)\) denotes the residual-stream representation passed to the intensity network. _evolve_and_get_intensity_at_sampled_dts evolves the same representation at quadrature times. The loss is the negative marked event log-intensity sum plus the integrated total intensity, using the shared Likelihood integration helper.

Implementation: easy_tpp/model/s2p2.py. The formulas above summarize this implementation, including its numerical choices, rather than asserting equivalence to every variant in the reference.

Original reference#

Deep Continuous-Time State-Space Models for Marked Event Sequences (as listed in the repository README).

Shipped preset#

This is the packaged model fragment. Configuration and presets explains how it merges with the dataset and shared trainer presets.

trainer_config:
  batch_size: 256
  shuffle: True
  optimizer: adam
  learning_rate: 1.e-2
  valid_freq: 1
  use_tfb: False
  metrics: [ 'acc', 'rmse' ]
  seed: 2019
  gpu: -1  # ID of GPU to use. Set to -1 to use CPU instead. `mps` backend could lead to incorrect results, please use CPU or CUDA.
model_config:
  hidden_size: 128  # Number of dimensions for u_t and y_t, labeled as H in the paper.
  loss_integral_num_sample_per_step: 10  # How many time points to use to estimate the integrated intensity between each pair of subsequent events for the log-likelihood.
  use_mc_samples: True  # Use Monte-Carlo sampling for the integral estimation. If False, uses a quadrature with a grid of evenly spaced points.
  num_layers: 4  # Number of LLH layers.
  model_specs:
    P: 16  # Number of dimensions for the hidden state x_t, labeled as P in the paper.
    dropout_rate: 0.1  # Dropout rate, used immediately after the activation function between layers but before the normalization. Formally, we set u^{(l+1)}_t = LayerNorm(dropout(\sigma(y^{(l)}_t)) + u^{(l)}_t).
    act_func: gelu  # gelu | half_glu | full_glu  # Activation function to use between layers.
    for_loop: True  # If enabled, uses for-loop for computing the recurrence in the LLH layers. If disabled, uses a parallel scan.
    pre_norm: False  # Should be set to False. If True, uses a LayerNorm on the inputs to a LLH layer.
    post_norm: True  # Should be set to True. If True, uses a LayerNorm on the outputs of a LLH layer (after transforming and adding the residual).
    int_forward_variant: False  # Should be set to False. If True, uses u_{t_i} as the ZOH constant for u_t with t \in (t_i, t_{i+1}].
    int_backward_variant: True  # Should be set to True. If True, uses u_{t_{i+1}-} as the ZOH constant for u_t with t \in (t_i, t_{i+1}].
    relative_time: True  # If True, predicts the scaling factor to be applied to the dynamics between each pair of subsequent events. See Sec. 3.3 of the paper.
  thinning:
    num_seq: 10
    num_sample: 1
    num_exp: 500
    look_ahead_time: 10
    patience_counter: 5
    over_sample_rate: 5
    num_samples_boundary: 21
    dtime_max: 5
    num_step_gen: 1

API#

easy_tpp.model.S2P2 · EasyTPP Models