ServiceNow / N-BEATS

N-BEATS is a neural-network based model for univariate timeseries forecasting. N-BEATS is a ServiceNow Research project that was started at Element AI.
Other
508 stars 116 forks source link

NBeats.forward() #7

Closed chenjw505 closed 3 years ago

chenjw505 commented 3 years ago

Hi, In the 'nbeats.py', the class NBeats:

class NBeats(t.nn.Module):

    def __init__(self, blocks: t.nn.ModuleList):
        super().__init__()
        self.blocks = blocks

    def forward(self, x: t.Tensor, input_mask: t.Tensor) -> t.Tensor:

        residuals = x.flip(dims=(1,))
        input_mask = input_mask.flip(dims=(1,))

        forecast = x[:, -1:]
        for i, block in enumerate(self.blocks):
            backcast, block_forecast = block(residuals)
            residuals = (residuals - backcast) * input_mask  
            forecast = forecast + block_forecast
        return forecast

in the forward funtion, why do this operation: ‘residuals = x.flip(dims=(1,))’ ???

dmitri-carpov commented 3 years ago

Hello, The inverse time axis was used for seasonality model formulation convenience. And it should not have any effect on generic model.

chenjw505 commented 3 years ago

thank u