autopycoin.layers.GenericBlock#
- class autopycoin.layers.GenericBlock(*args, **kwargs)[source]#
Generic block definition as described in the paper.
This layer represents the smaller part of a nbeats model. We can’t have explanation from this block because g coefficients are learnt.
- Parameters
- label_width
int Horizon time to forecast.
- g_forecast_neurons
int Dimensionality if the gf layer.
- g_backcast_neurons
int Dimensionality if the gb layer.
- n_neurons
int Number of neurons in Fully connected layers.
- drop_rate
float Rate of the dropout layer. This is used to estimate the epistemic error. Expected a value between 0 and 1. Default to 0.1.
- label_width
Notes
input shape: N-D tensor with shape: (…, batch_size, time step). The most common situation would be a 2D input with shape (batch_size, time step).
output shape: N-D tensor with shape: (…, batch_size, units). For instance, for a 2D input with shape (batch_size, units), the output would have shape (batch_size, units). With a QuantileLossError with 2 quantiles or higher the output would have shape (quantiles, batch_size, units). If you add 2 variables, the output would have shape (variables, quantiles, batch_size, units).
Examples
>>> from autopycoin.layers import GenericBlock >>> from autopycoin.models import Stack, NBEATS >>> from autopycoin.losses import QuantileLossError >>> generic_block = GenericBlock(label_width=10, ... n_neurons=16, ... g_forecast_neurons=16, ... g_backcast_neurons=16, ... drop_rate=0.1, ... name="generic_block") >>> generic_blocks = [generic_block for _ in range(3)] >>> generic_stacks = Stack(generic_blocks, name="generic_stack") >>> # Model definition and compiling >>> model = NBEATS([generic_stacks, generic_stacks], name="generic_NBEATS")
- Attributes
- coefficient_factory(output_last_dim: int, neurons: int) tensorflow.python.framework.ops.Tensor[source]#
Compute the coefficients used in the last layer a.k.a g layer. This function is used in _get_forecast_coefficients and _get_backcast_coefficients.
- property g_backcast_neurons#
Return the dimension of the gb layer.
- property g_forecast_neurons#
Return the dimension of the gf layer.