Neural Temporal Logic Programming

1 INTRODUCTION . Complex time series data is present across many data modalities such as sensors , records , audio , and video data . Typically there are composite events of interest in these time series which are composed of other atomic events in a certain order ( Liu et al. , 1999 ; Chakravarthy et al. , 1994 ; Hinze , 2003 ) . An example is a health symptom that can be observed in a doctor ’ s report . Atomic events , such as patient vitals and medications , and their temporal relations dictate an underlying causal rule leading to the composite event symptom . These rules may be unknown but useful to recover ( Kovačević et al. , 2013 ; Guillame-Bert et al. , 2017 ) . Recent methods leverage the advances in highly parameterized deep architectures to learn latent representations of atomic event data ( Pham et al. , 2017 ; Chen et al. , 2018 ; Choi et al. , 2019 ) , with the increasing availability of large temporal datasets . Methods , such as LSTM ( Hochreiter & Schmidhuber , 1997 ) or Transformer ( Vaswani et al. , 2017 ) based architectures , provide stateof-the-art performance in terms of composite event inference . However , it is uncertain whether the latent representations learn the underlying causal sequence of events or overfit spurious signals in the training data . Having representations faithful to causal mechanisms is advantageous for interpretability , out-of-distribution generalization , and adapting to smaller data sets . Therefore it is important to leverage parametric models that can handle data noise while providing a mechanism to extract explicit temporal rules ( Carletti et al. , 2019 ) . Extracting explicit logic rules has been studied through Inductive Logic Programming ( ILP ) methods ( Muggleton , 1991 ; Muggleton & De Raedt , 1994 ) and have been leveraged in parametric fashions as well ( Yang et al. , 2017 ; Evans & Grefenstette , 2018 ; Rocktäschel & Riedel , 2017 ) . ILP starts with set of background knowledge , consisting of grounded atoms ( i.e . facts which do not contain variables ) such as location ( Braves , Atlanta ) , where the predicate location determines the relationship between the items Braves and Atlanta . There are set of labels from which rules should be learned . The task is to construct a set of rules , when executed over the background knowledge , entail the provided labels . Given the label InLeague ( Braves , NL East ) and the background knowledge ( Figure 1 ILP Input ) as input , a candidate rule is InLeague ( Team , League ) : = Location ( Team , City ) ∧ Division ( City , League ) . Here InLeague ( Team , League ) is the head of the rule consisting of an atom with variables Team , League as items . The body consists of two atoms and when these atoms exist on the background knowledge the rule is evaluated as true.We apply ILP over real world temporal data , however learning such rules poses three key challenges . Temporal Background Knowledge First , ILP methods operate over an existing grounded background knowledge . The temporal case does not have this knowledge when operating over raw time series . For example in a baseball video , grounded atomic events pitch or swing , or grounded predicates such as before ( pitch , swing ) are not explicitly provided . By nature , the video would be labeled with a higher level composite event description , such as `` Player A ’ s home run '' instead of individual atomic events and their corresponding temporal predicates . Such atoms can be extracted using a model in a probabilistic fashion at each time point , and a temporal ILP method should handle this uncertainty . The temporal predicates between these probabilistic atomic events can be applied in a rule-based manner ( ex . t1 < t2 → before ) , but due to the noisy nature of extracted atomic events , the predicate predictions should be robust to consistent noise in the atomic event data . Atomic Event Relevance Second , ILP works learn consistent rules that satisfy a path in the background knowledge given the terms in the labels , such as InLeague ( Braves , NL East ) . The labels are nullary predicates in the temporal case , so the relevant source and target atomic events and predicates to use for rule induction are unknown . In our example , we know from the video we have a label strike , but are not told when it occurred or what other events , such as pitch , swing , and miss are needed to compose a rule for strike . Without a prior on which atomic events to search from , we must consider all pairwise temporal relations between atomic events in the input . This leads to a combinatorial search of all pairwise events for each predicate in the temporal rule body . Multi-Event Labels Third , ILP domains work on disjoint labels , while in time series , multiple composite events could occur in each input . In our baseball video , such as a highlight reel , composite event labels strike , steal and their corresponding atomic events can co-occur in a single video . This further extends the search space of atomic events we consider for each composite event rule . We illustrate these differences in Figure 1 and further discuss these challenges regarding search complexity in Appendix A . To address these challenges , Neural TLP operates on two key steps . Parameter Learning First Neural TLP inputs probabilistic atomic events and learns parameters to infer temporal predicates between atomic events . We represent the atomic event data in an intervalbased representation to efficiently predict all pairwise predicates between atomic events . The inferred predicates are then projected to predict the composite event labels . Structure Learning When the predicate parameters are learned , Neural TLP learns a sparse vector to select the correct rule over the combinatorial space of possible rules . To prune the search space , we use the learned projected weights to select candidate grounded predicates per composite event . We evaluate our method on a synthetic video dataset to empirically test our temporal rule induction performance . Additionally , we apply our framework to provide relevant rules in the healthcare domain , which were verified by doctors . 2 PROBLEM FORMULATION . We define the complete set of atomic events X = { x1 , x2 , . . . , x|X | } along a timeline T . These atomic events can be existing features in time series data or user defined features of interest . A temporal logic rule r ( Xr , Tr ) can be defined as using a subset of N ≤ |X | atomic events Xr = { xu } Nu=1 ⊆ X , and their associated time intervals Tr = { tu } Nu=1 ⊆ T . The time intervals consists of start and end times tu = [ tustart , tuend ] . These intervals indicate durational events and we can also initialize instantaneous events occurring at one time point where tustart = tuend . A rule is evaluated as true if the corresponding atomic events xu are present and are in correct ordering with respect to the intervals tv of other events xv : r ( Xr , Tr ) : = ( ∧ xu∈Xr xu ) ∧ ( ∧ tu , tv∈Tr pi ( tu , tv ) ) The temporal predicates pi ∈ { before , during , after } = P represent a simplified subset of Allen ’ s Temporal Algebra ( Allen , 1983 ) . We simplify the notation of the rules as a conjunction of temporal predicates between observed events , where the event time intervals are implicit : r : = n∧ xu , xv∈Xr pi ( xu , xv ) ( 1 ) For example , the grounded predicate before ( pitch [ 2,2.7 ] , swing [ 3,3.5 ] ) would evaluate to true . These underlying causal rules r induce the composite event labels r → yr seen in the data . Multiple composite events of interest can co-occur during the same time series sample T which we denote as y = { yr } |R| ∈ { 0 , 1 } |R| . Any yr = 1 indicates the latent rule r occurred over T resulting in label yr . While T contains precise atomic event interval information , the observed time series T̃ consists of a sequence of probabilistic atomic events from times [ 1 , T ] . Potentially k different objects T̃ i compose the final time series data T̃ = ⋃k i=1 T̃ i . Examples of objects can be multiple concurrent sensor data , or tracking multiple people moving within a video . Then the input T̃ is formulated as MT ∈ [ 0 , 1 ] k×|X|×T across object , atomic event , and probability dimensions respectively . The temporal ILP task is to recover all underlying rules R given m samples of inputs and labels { ( MTi , yi ) } mi=1 . In Neural TLP this involves learning parameters for the predicates between atomic events and then learning the combination of grounded predicates that induce each r ∈ R . 3 NEURAL TEMPORAL LOGIC PROGRAMMING . Neural TLP operates in two stages . The parameter learning stage learns how to compress the temporal data and learns parameterized temporal predicates . Once these parameters are learned , the structure learning stage learns which conjunctive combination of pairwise atomic event predicates is associated with each composite event label . This conjunction composes the rule r for label yr and is jointly computed for all R. An overview of the framework is presented in Figure 2 . 3.1 PARAMETER LEARNING STAGE . Temporal Compression Starting from the raw probabilistic atomic event data , we first compress the timeline through convolution . This 1D convolution over the temporal dimension compresses and smooths the timeline to mitigate noise from spurious events . Here the convolution kernel K|X |×l of length l is learned per atomic event . We also parameterize α as an extra degree of freedom to scale these convolved scores , which is useful when computing the intermediate predicates downstream . MC ∈ Rk×|X|×t = α · conv_1D ( MT ∈ [ 0 , 1 ] k×|X|×T , K ) ( 2 ) The time information is incorporated by multiplying the time dimension MD into compressed events : MA ∈ Rk×|X|×t = MC ⊙ MD . Here MD has the same dimensions as MC , but the temporal dimension is enumerated from [ 1 , t ] , where MD : , : ,l = l. This can be thought as a positional encoding . For example if we look at the sample compressed scores for a single object i and atomic event j MCi , j,6:10 = [ .01 , .05 , .7 , .7 , .03 ] and MDi , j,6:10 = [ 6 , 7 , 8 , 9 , 10 ] then MAi , j,6:10 = [ .06 , .35 , 5.6 , 6.3 , .3 ] . Intuitively we can see that from MAi , j,6:10 that ( 1 ) atomic event j occurs when the scores are high at 5.6 and 6.3 and that ( 2 ) score 6.3 occurs after score 5.6 due to the multiplied time index . This temporal representation provides a path to compute precise time intervals of atomic event occurrences and define predicates to compare atomic event intervals . Predicate Modeling From the compressed timelines , we determine the temporal predicates between atomic events . These relations are computed in a pairwise manner for all atomic events ∀xu , xv ∈ X occurring in object i through a small network which we call Temporal Predicate Network ( TPN ) . For notation sake here , we represent the atomic event u ’ s timeline for object i as tiu = MAi , u , : ∈ Rt and correspondingly for atomic event v. We denote TPN as gθ ( tiu , t i v ) , which takes pairwise atomic event timelines and predicts a temporal predicate p ∈ P to indicate the relationship between the atomic events . Methods such as Temporal Relation Networks ( Zhou et al. , 2018 ) learn these predicates between video events by sampling frames throughout the video . The timelines can be long in our setting , and events can occur sparsely , making sampling timelines expensive and noisy . To efficiently compute these relations , we would like to recover each event ’ s underlying start and end time intervals . From intervals , we can encode strong inductive biases to predict the predicates.We are working with continuous time series scores in tiu , t i v , so the intervals have to be extracted as the first step in TPN . To compute the start of an event interval , we create a mask to identify the atomic event noise . Those values will be below some small value ϵ , corresponding to noise in the timeline . We learn the convolution scalar α from Equation 2 to scale scores corresponding to active atomic event occurrences above ϵ while keeping scores corresponding to atomic event noise below ϵ . Then the mask is added to the time series , and a min is performed to get the start of the active atomic event interval . Afterwards the min of the mask is subtracted to remove any effect of the mask on the start value . tmask = ( max ( t i u ) + ϵ ) · ( tiu < ϵ ) ( 3 ) ustart = min ( t i u + tmask ) −min ( tmask ) ( 4 ) To get the end of the event interval we simply compute uend = max ( tiu ) since we multiplied the event scores with the time index earlier . This interval computation from the input time series is visualized in Figure 3 . This is computed similarly for the other pairwise event v : [ vstart , vend ] . Given the start and end times for the event pairs u , v , the un-normalized predicate scores are computed as : before ( u , v ) = vstart − uend ( 5 ) after ( u , v ) = ustart − vend ( 6 ) during ( u , v ) = min ( { vend − ustart , uend − vstart } ) ( 7 ) Although we use 3 predicates in our model , similar scores can be developed for more fine grained predicates . Then the values are aggregated as p = [ before ( u , v ) ; during ( u , v ) ; after ( u , v ) ] to compute normalized predictions as p = softmax ( p−βγ ) . Here β and γ and scale and shift parameters learned from data . Our predicates scores assume that intervals for both u and v occur , so if either event doesn ’ t occur we suppress all predicate predictions : supp = min ( { uend − ustart , vend − vstart } ) ( 8 ) pi = min ( { pi , supp } ) ( 9 ) Since we leverage a simple interval representation to compare atomic event objects , we can scale comparing atomic events within the object and between the other k−1 objects : xu ∈ X , xv ∈ ( X×k ) . This second-order interaction information is useful if we want to know if , for example , two events occurred simultaneously within different objects . For a single object i , these relations are computed for all pairwise predicates through TPN in MP ∈ R|X |× ( |X |×k ) ×|P| = Rk×|X|×|X|×|P| . Aggregating over all objects k , we get MQ = [ MP1 ; . . . ; MPk ] ∈ Rk 2×|X|×|X|×|P| . We marginalize over the object dimension to get our final pairwise relation matrix MR = ∑ i MQi , : , : , : ∈ R |X |×|X|×|P| . Composite Event Prediction The final inference step from the pairwise relational predicates to the composite events labels is carried out by fϕ . This is a linear projection function fϕ ( MR ) : = σ ( dropout ( vec ( MR ) ) W ) used to infer the composite event labels ŷ . Here we flatten MR as vec ( MR ) ∈ R|X |·|X |·|P| and regularize it by randomly masking out the grounded predicates ( Srivastava et al. , 2014 ) . This representation is then projected to the label space using W ∈ R ( |X |·|X |·|P| ) ×|y| before passing the un-normalized results through a sigmoid function σ. W learns what grounded relational predicates pi ( xu , xv ) , such as before ( pitch , swing ) , correspond to each composite event label . These weights will also be useful for extracting the rules , in the structure learning stage .

Summary: The paper proposes an end-to-end differentiable strategy (called neural TLP) to learn unknown temporal relations between atomic events (like after(miss, swing), “miss occurs after swing” in the baseball example), subsequently used to predict composite events (like strike). The strategy consists of a cascade of a smoothing stage to filter  out noise from the input time series, an interval time extractor, a stage predicting temporal relations (such as before, after and during) and a linear output layer. Furthermore, the paper proposes a post-hoc procedure to extract propositional logical rules relating atomic events to composite ones from the last layer. The performance of the proposed strategy is evaluated on video recognition (CATER) and healthcare (MIMIC-III) datasets against two baselines, namely a LSTM neural net and a simplified version of the proposed strategy.