understanding what pattern DeepAR learns and how it works

Jose_Peeterson: <p>I am trying to understand how the following simple pattern from a synthetic count time series is learnt using DeepAR. <a href="https://arxiv.org/abs/1704.04110" class="inline-onebox" rel="noopener nofollow ugc">[1704.04110] DeepAR: Probabilistic Forecasting with Autoregressive Recurrent Networks</a></p>
<p><a href="https://i.stack.imgur.com/6J10b.png" rel="noopener nofollow ugc"><img src="https://i.stack.imgur.com/6J10b.png" alt="enter image description here" width="690" height="361"></a></p>
<p>The count time series is generated from a negative binomial distribution with parameters n = 9 and p = 0.5 every 4 hours. The interval in-between has magnitude = 0.</p>
<p>I want to understand how learning happens.</p>
<p>The architecture is given below</p>
<p><a href="https://i.stack.imgur.com/VXj2B.png" rel="noopener nofollow ugc"><img src="https://i.stack.imgur.com/VXj2B.png" alt="enter image description here" width="690" height="347"></a></p>
<p>Let’s use the example above.</p>
<p>Let’s ignore the covariates for now.</p>
<p>Let’s say we used the unrolled network representation.</p>
<p>Say time series is 6,0,0,0,4,0,0,0,7,0,0,9,0,0,0</p>
<p>The inputs (say [6,0,0,0]) are just any sub-sequence of encoder length (say 4) from the time series. The outputs (say [0,0,0,4]) are inputs time shifted right by 1 time step.</p>
<p>The time series have some periodic behaviour like in the first figure above. However, the inputs given during training can be any sub-sequence (e.g. input [0,0,4,0] output [0,4,0,0] ) i.e. phase-shifted.</p>
<p>What is the pattern learnt here in order to tune the parameter set of the negative binomial, ( μt and αt) at each cell, Pt. t = 1,2,3,4? (P1 = ( μ1 and α1))<br>
The parameters at each cell cannot be a fixed value that converges to some constant because the input coming is phase shifted each time. The time steps are not absolute.</p>
<p>There are 4 sub-sequence before the pattern repeats. Therefore, 4 parameter sets need to be learnt.</p>
<p>6,0,0,0</p>
<p>0,0,0,4</p>
<p>0,0,4,0</p>
<p>0,4,0,0</p>
<p>4,0,0,0</p>
<p>If the high value occurs at any other time step apart from the first then the last time step prediction is always zero.</p>
<p>If a high value occurs in the first-time step (e.g. 6,0,0,0) then we know that a high value has to be predicted for the last time step (e.g. 0,0,0,4).</p>
<p>However, the high values must be learned that they come from a negative binomial distribution with certain parameters.</p>
<p>The high values from the past sub-sequences are aggregated in the hidden states and do they help to tune the parameters of the negative binomial distribution?</p>
<p>I know that the hidden states tell if certain patterns have been observed in the past sub-sequences. Can they also “count” each value of the input sub-sequence to form a “histogram” and then deduce the parameters of the distribution.</p>
<p>Say the hidden state vector is very long.<br>
A part of the vector with 30 elements represents a particular time step, and each element can be a normalized proportion of observed counts for each of the 0 to 29 elements in the previous input sub-sequences. Similarly, for other time steps we have other parts of the hidden states vector that represent the normalized proportion of observed counts.<br>
Is this the correct understanding?</p>
<p>How does the network learn these proportions?</p>
<p>Once the hidden state is learnt then its transformed into a scalar parameters μt and αt of the negative binomial distribution like shown in the 2nd equation below.</p>
<p><a href="https://i.stack.imgur.com/xjUdd.png" rel="noopener nofollow ugc"><img src="https://i.stack.imgur.com/xjUdd.png" alt="enter image description here" width="690" height="142"></a></p>
<p>In order for the hidden state to be learnt it has to be guided from wrong values in the start of training to correct values. This is done by loss function minimization (Negative log likelihood).</p>
<p><a href="https://i.stack.imgur.com/DWxcf.png" rel="noopener nofollow ugc"><img src="https://i.stack.imgur.com/DWxcf.png" alt="enter image description here" width="690" height="303"></a></p>
<p>The likelihood function is defined as below. As supervisory signal (i.e. right time shifted input), we are providing the joint distribution for the time steps. Through this we are saying that certain sequences with the right parameters, μt and αt are more likely to occur than others.</p>
<p><a href="https://i.stack.imgur.com/WJe82.png" rel="noopener nofollow ugc"><img src="https://i.stack.imgur.com/WJe82.png" alt="enter image description here" width="690" height="212"></a></p>
<p>However, in every training step input sub-sequence will be phase shifted so will the paramters<br>
μt and αt adjust their positions on the time steps according to the phase? or should we just NOT use sliding windows during training? or should we use more than 4 time steps or more time steps than the largest period in order for the lstm to identify which parameters belong to which time steps?</p>