WSMTHP#

Summary#

A causal Transformer trained with weighted score matching and a mark cross-entropy objective; evaluation follows a likelihood path.

Intensity and objective#

_get_intensity uses history-dependent slope and base heads:

\[\lambda_k(u\mid h)=\operatorname{softplus} \left(\tanh(a_k(h))u+b_k(h)\right).\]

_compute_score computes \(s=\partial_u\log\lambda_{\mathrm{tot}}-\lambda_{\mathrm{tot}}\). In training, loglike_loss sums \(\tfrac12 w s^2+w\,\partial_u s+s\,\partial_u w\), with mark cross-entropy and an optional survival loss. _wsm_weights selects the weighting function. Validation and testing call nll_loss, which uses sampled likelihood integration instead of the training objective. Survival-related options and prediction corrections are implemented in wsm_thp.py; the shipped preset leaves survival loss disabled.

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

Original reference#

Is Score Matching Suitable for Estimating Point Processes? (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: 64
  shuffle: False
  optimizer: adam
  learning_rate: 1.e-3
  valid_freq: 10
  use_tfb: False
  metrics: [ 'acc', 'rmse' ]
  seed: 2019
  gpu: -1
model_config:
  hidden_size: 16            # Transformer model dimension d_model
  num_layers: 2              # Number of Transformer encoder layers
  num_heads: 2               # Number of attention heads
  dropout_rate: 0.1
  loss_integral_num_sample_per_step: 20  # kept for EasyTPP compatibility
  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
  model_specs:
    h_type: two_side_op      # weight function; only 'two_side_op' is currently supported
    T_mode: train_global     # manual | train_global | batch
    max_observed_time:       # used when T_mode=manual
    d_inner: 32              # FFN hidden dimension (default: hidden_size * 2)
    with_survival: false     # optional finite-window survival classifier from the paper
    alpha_survival: 10.0     # weight for the survival classification loss when enabled
    alpha_neg: 10.0          # class weight for non-terminal events in the survival loss

API#

easy_tpp.model.WSMTHP · EasyTPP Models