philipperemy/keras-tcn

Receptive field description and examples

strokovnjaka opened this issue · 2 comments

My 5cents to the "In theory, the 2 is not justified. We are still not sure why in practice we need to add this 2 in the formula." question, as stated in the README.

The 2 is there because there are two Conv1d layers in a single ResidualBlock.

First, note that the cited paper states "This gives us two ways to increase the receptive field of the TCN: choosing larger filter sizes k and increasing the dilation factor d, where the effective history of one such layer is (k − 1)d."
In my opinion, that defines receptive field as "maximum number of steps back in time from current sample at time T, that a filter from (block, layer, stack, TCN) can hit", or something in that sense.
The README seems to define receptive field as "maximum number of samples that filters from (block, layer, stack, TCN) can hit", which is basically effective history + 1, so no big deal there.

So, a level i ResidualBlock's effective history is Eh = 2⋅(k-1)⋅di, with k being kernel size, and di being dilation for the ResidualBlock at level i.

Next, as ResidualBlocks are stacked in a stack, its Eh = Σ(2⋅(k-1)⋅di) = 2⋅(k-1)⋅Σdi.

Next, as N stacks are stacked, their Eh = N⋅2⋅(k-1)⋅Σdi.

As receptive field seems to be effective history plus current sample at time T, the formula Rfield = 1 + 2⋅(k-1)⋅N⋅Σdi is correct.

As far as example figures go, they do not match the formula. For the first figure of single stack 16 != 31 = 1 + 2⋅(2-1)⋅1⋅(1+2+4+8), and so on for others. Example figures include single Conv1d per layer, so the correct formula would be Rfield = 1 + (k-1)⋅N⋅Σdi (without the notorious 2).

Description for the formula states "...where Ns is the number of stacks, Nb is the number of residual blocks per stack...",
but formula references Nstacks. So instead of Ns use Nstacks, and somehow state that the number of residual blocks is
the number of di s in the formula (or, even better, replace the formula image)

To avoid confusion, stating the formula for the examples, as well as correcting formula's descriptions, would be great.
If, of course, the above is correct :)

@strokovnjaka thank you so much! I will update the README ;)